home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-144 < prev    next >
Text File  |  1996-04-16  |  136KB  |  3,647 lines

  1. C.S.M.P. Digest             Mon, 15 Apr 96       Volume 3 : Issue 144
  2.  
  3. Today's Topics:
  4.  
  5.         68K or PPC struct alignment?
  6.         Apple's Game API
  7.         CopyBits-Yet again I ask
  8.         Determining Memory Size Needed by GWorld
  9.         Direct-Optimized Access to PixMap
  10.         Display Manager
  11.         Fast writes to disk?
  12.         How should data be organized for read-write to files?(beginner)
  13.         How to Do Registration Codes
  14.         How to find CTB devices ?
  15.         How to make an app scriptable
  16.         Macsbug 6.5.3 slower at stepping?
  17.         NewGWorld Memory Leak?
  18.         Optimizing RGB pixel operations on PPC?
  19.         UMPA Awards Last week for Nominations
  20.         [ANN] MoreFiles v1.4.2 now available
  21.         [Q] Selecting a Serial Port
  22.  
  23.  
  24.  
  25. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  26. (pottier@clipper.ens.fr).
  27.  
  28. The digest is a collection of article threads from the internet
  29. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  30. csmp.games. It is designed for people who read news semi-regularly and
  31. want an archive of the discussions.  If you don't know what a
  32. newsgroup is, you probably don't have access to it. Ask your systems
  33. administrator(s) for details. If you don't have access to news, you
  34. may still be able to post messages to the group by using a mail server
  35. like anon.penet.fi (mail help@anon.penet.fi for more information).
  36.  
  37. Each issue of the digest contains one or more sets of articles (called
  38. threads), with each set corresponding to a 'discussion' of a particular
  39. subject.  The articles are not edited; all articles included in this digest
  40. are in their original posted form (as received by our news server at
  41. nef.ens.fr).  Article threads are not added to the digest until the last
  42. article added to the thread is at least two weeks old (this is to ensure that
  43. the thread is dead before adding it to the digest).  Article threads that
  44. consist of only one message are generally not included in the digest.
  45.  
  46. The digest is officially distributed by two means, by email and ftp.
  47.  
  48. If you want to receive the digest by mail, send email to listserv@ens.fr
  49. with no subject and one of the following commands as body:
  50.     help                        Sends you a summary of commands
  51.     subscribe csmp-digest Your Name    Adds you to the mailing list
  52.     signoff csmp-digest            Removes you from the list
  53. Once you have subscribed, you will automatically receive each new
  54. issue as it is created.
  55.  
  56. The official ftp info is ftp://ftp.dartmouth.edu/pub/csmp-digest.
  57. Questions related to the ftp site should be directed to
  58. scott.silver@dartmouth.edu.
  59.  
  60. -------------------------------------------------------
  61.  
  62. >From timmyd@netcom.com (Tim DeBenedictis)
  63. Subject: 68K or PPC struct alignment?
  64. Date: Thu, 28 Mar 1996 23:03:34 GMT
  65. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  66.  
  67. Hi everybody-
  68.  
  69. I'm wriring a program which needs to read some data files on both 68K and
  70. PowerPC Macs.  Since the guy who wrote the program was not clever enough 
  71. to make his structs come out the with the same size and byte alignment on 
  72. both platforms :), I need to make CodeWarrior choose either 68K or PPC 
  73. struct alignment to make things work without crashing.
  74.  
  75. I know that the PowerPC, especially 603 and 604, are very sensitive to 
  76. bad byte alignment in terms of performance.  However, if I choose PPC 
  77. struct alignment, will my 68K versions suffer a great performance hit?
  78.  
  79. And will the reverse be true if I choose 68K struct alignment?
  80.  
  81. Thanks in advance,
  82.  
  83. -Tim DeBenedictis
  84. timmyd@netcom.com
  85.  
  86.  
  87. +++++++++++++++++++++++++++
  88.  
  89. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  90. Date: Fri, 29 Mar 1996 01:53:29 -0500
  91. Organization: Carnegie Mellon, Pittsburgh, PA
  92.  
  93. timmyd@netcom.com (Tim DeBenedictis) writes:
  94. > I'm wriring a program which needs to read some data files on both 68K and
  95. > PowerPC Macs.  Since the guy who wrote the program was not clever enough 
  96. > to make his structs come out the with the same size and byte alignment on 
  97. > both platforms :), I need to make CodeWarrior choose either 68K or PPC 
  98. > struct alignment to make things work without crashing.
  99. > I know that the PowerPC, especially 603 and 604, are very sensitive to 
  100. > bad byte alignment in terms of performance.  However, if I choose PPC 
  101. > struct alignment, will my 68K versions suffer a great performance hit?
  102.  
  103. PPC alignment is more aligned than 68K alignment. I mean, more things
  104. will be aligned to 4-byte boundaries in PPC than 68K, if you see what
  105. I mean, and so on.... So a 68K program will never take a speed hit
  106. because of PPC alignment. However, the structs will be bigger, so you
  107. take a memory hit. (I suppose this could impact the speed, too,
  108. because the data cache will fill up faster -- but this is really not
  109. worth worrying about until it's *really* necessary.)
  110.  
  111. > And will the reverse be true if I choose 68K struct alignment?
  112.  
  113. A PPC program will take a speed hit if you give it 68K alignment.
  114. However, the difference may be unnoticeable. Do some tests.
  115.  
  116. You can also use #pragmas to align particular structure types to 68K
  117. alignment, when the rest of the program is in PPC alignment. This
  118. lessens the speed hit, obviously. This is often a good idea,
  119. especially if those structs are only used in a few places.
  120.  
  121. --Z
  122.  
  123. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  124.  
  125. +++++++++++++++++++++++++++
  126.  
  127. >From Keith Wiley <keithw@wam.umd.edu>
  128. Date: Fri, 29 Mar 1996 10:27:33 -0500
  129. Organization: University of Maryland College Park
  130.  
  131. > I'm wriring a program which needs to read some data files on both 68K and
  132. > PowerPC Macs.  Since the guy who wrote the program was not clever enough 
  133. > to make his structs come out the with the same size and byte alignment on 
  134. > both platforms :), I need to make CodeWarrior choose either 68K or PPC 
  135. > struct alignment to make things work without crashing.
  136.  
  137. How is this done?  Is it a compiler switch in the preferences, a .h file 
  138. of some sort, or do I need to actually learn new C code in order to 
  139. utilize this?
  140.  
  141. > I know that the PowerPC, especially 603 and 604, are very sensitive to 
  142. > bad byte alignment in terms of performance.  However, if I choose PPC 
  143. > struct alignment, will my 68K versions suffer a great performance hit?
  144.  
  145. I'd like to know how it affects the 601 if anyone knows.  This is 
  146. probably my problem.
  147.  
  148. . . .. ... ..... ........ ............. .....................
  149. .. ... ..... ....... ........... ............. .................
  150. . .. .... ........ ................ ................................
  151. Keith Wiley, Electrogenetic Engineer             *
  152. University of Maryland at College Park            *   * *     *   *      *
  153. email:  keithw@wam.umd.edu                      ***    **   * *    **     *
  154. world wide web:  http://www.wam.umd.edu/~keithw        *     **   **    ***
  155.  
  156. +++++++++++++++++++++++++++
  157.  
  158. >From tonyn@tiac.net (Tony Nelson)
  159. Date: Mon, 01 Apr 1996 10:52:27 -0500
  160. Organization: The Internet Access Company
  161.  
  162. In article <timmydDp02pz.EGv@netcom.com>, timmyd@netcom.com (Tim
  163. DeBenedictis) wrote:
  164.  
  165. > I'm wriring a program which needs to read some data files on both 68K and
  166. > PowerPC Macs.  Since the guy who wrote the program was not clever enough 
  167. > to make his structs come out the with the same size and byte alignment on 
  168. > both platforms :), I need to make CodeWarrior choose either 68K or PPC 
  169. > struct alignment to make things work without crashing.
  170.  
  171. All you need is to be able to read those brain-damaged files correctly. 
  172. Just declare two sets of types, using appropriate filler to get things in
  173. the right place, wrapping the type declarations in the appropriate pragma
  174. options align directives.  See Apple's header files and the CodeWarrior
  175. C/C++/Asm Lang Ref.  Leave the rest of your program (all the internal
  176. stuff) at native alignment.  Pick one of the alignments when you write
  177. files, or write everything byte-by-byte (usually big-end first so you can
  178. assemble words and longs with just shift and or) so the file isn't machine
  179. specific.
  180. ____________________________________________________________________
  181. TonyN.:'                                              tonyn@tiac.net
  182.       '
  183.  
  184. ---------------------------
  185.  
  186. >From brianm@caledonia.polaristel.net (Brian P. McCarty)
  187. Subject: Apple's Game API
  188. Date: Tue, 26 Mar 1996 13:13:09 -0600
  189. Organization: totally disorganized
  190.  
  191. If haven't read it, I suggest you look at MacWEEK's article on Apple's
  192. game API. You can get it at 
  193. http://www.zdnet.com/macweek/mw_1012/news_game_makers.html
  194.  
  195. The article mentions a apple games site at http://dev.info.apple.com/games
  196. when I went there it said it would be open March 31.
  197. (it actually took me to http://dev.info.apple.com/evangelism/games/games.html)
  198.  
  199. I tried the macweek address mar 26 and it was too busy, I did connect on
  200. March 25. The apple site did display on March 26 (your milage may vary)
  201.  
  202. Brian
  203.  
  204. -- 
  205. Brian P. McCarty, N9IWP
  206. e-mail:brianm@caledonia.polaristel.net
  207. snail-mail:410 S. Ramsey, Apt. 4 Caledonia, MN 55921-1116
  208. ICBM:43deg 38' 05" N  91deg 29' 48" W
  209.  
  210. ---------------------------
  211.  
  212. >From Brewski@twics.com (Brian Sweeney)
  213. Subject: CopyBits-Yet again I ask
  214. Date: 23 Mar 1996 15:33:45 GMT
  215. Organization: All USENET -- www.net-link.com
  216.  
  217. I have read the books,downloaded the technical notes from apple etc but I cannot
  218. find the reason why my Copybits routine copying from a PixMap to a GWorld works
  219. on Non-Power Macintoshes but does not copy properly on a Power Mac.
  220. Both the srcRect and the DstRect are the same size ,Both PixMaps are 256 colors
  221. and the transfer mode is SrcCpy.And it works on Non-Power Macs.
  222. Has anybody out there have an inkling of what could cause the Copybits
  223. routine to differ between Non power Macs and Power Macs.
  224.  
  225. Better yet ,if anybody has a simple code snippet of copying a dummy pixmap
  226. to a GWorld that works on a Power Mac I would be eternally grateful.
  227.  
  228. +++++++++++++++++++++++++++
  229.  
  230. >From heaney@crl.com (John S. Heaney)
  231. Date: 23 Mar 1996 13:44:19 -0800
  232. Organization: CRL Dialup Internet Access    (415) 705-6060  [Login: guest]
  233.  
  234. In article <Brewski-2303962352230001@c12.dial.twics.com>,
  235. Brian Sweeney <Brewski@twics.com> wrote:
  236. >I have read the books,downloaded the technical notes from apple etc but I cannot
  237. >find the reason why my Copybits routine copying from a PixMap to a GWorld works
  238. >on Non-Power Macintoshes but does not copy properly on a Power Mac.
  239. >Both the srcRect and the DstRect are the same size ,Both PixMaps are 256 colors
  240. >and the transfer mode is SrcCpy.And it works on Non-Power Macs.
  241. >Has anybody out there have an inkling of what could cause the Copybits
  242. >routine to differ between Non power Macs and Power Macs.
  243.  
  244. I had a similar situation to yours, although there's not enough 
  245. information here to know how similar. I was fading down one graphic and 
  246. fading up another. I faded down all 256 colors, drew the new graphics, 
  247. and faded up to the new clut. This technique relies on no color mapping 
  248. taking place when the new graphics are drawn because all the colors are 
  249. black. So, I did the ctSeed slam when drawing all my graphics.
  250.  
  251. This worked fine on my 68K machine, but failed when I ran the same 68K 
  252. application on a PowerMac. Note I am not talking about a native 
  253. application, but emulated. It drove me crazy until I found out that a bug 
  254. in my code was preventing the ctSeed slam from happening. Even so, it was 
  255. working on the 68K machine, but not on the PowerMac.
  256.  
  257. I really don't know what that means beyond the apparent fact that the two 
  258. platforms seem to differ in how they do color mapping. I don't know if 
  259. it's the onboard video or what. It may have even been the system version; 
  260. I was using 7.1 on the 68K machine and 7.5 on the PowerMac.
  261.  
  262. The whole color mapping thing is a bit of voodoo, as far as I can see. 
  263. For example, I've still yet to determine how to fade to pure black, draw 
  264. my new graphics and fade up to the new colors. I actually fade down to 
  265. almost black (256, 256, 256). This works fine except you can still see 
  266. the image if you turn the brightness of your monitor way up. 
  267.  
  268. It seems that if I fade to pure black then the Color Manager sees the
  269. first black as the end of the palette, which it isn't, of course. It then 
  270. seems to remap the colors of the new graphics to the same color black, 
  271. probably the first one. Then when the colors fade up, you get a white 
  272. screen or some other color mapping problem. It's pretty weird.
  273.  
  274. >Better yet ,if anybody has a simple code snippet of copying a dummy pixmap
  275. >to a GWorld that works on a Power Mac I would be eternally grateful.
  276.  
  277. I program in Prograph, so it probably wouldn't do you much good. See if
  278. any of this resonates with you and maybe you'll find some relevant details
  279. of your code that you could post. Maybe we'll get to the root of it
  280. someday. :)
  281.  
  282. -- 
  283. John Heaney              Time flies whether you're having fun or not.
  284. heaney@crl.com
  285.  
  286. +++++++++++++++++++++++++++
  287.  
  288. >From 'Digital Dave' Shields <digidave@vvstudios.com>
  289. Date: Mon, 25 Mar 1996 06:03:42 -0800
  290. Organization: Vanguard Vision Studios, San Francisco, CA
  291.  
  292. Brian Sweeney wrote:
  293. > I have read the books,downloaded the technical notes from apple etc but I cannot
  294. > find the reason why my Copybits routine copying from a PixMap to a GWorld works
  295. > on Non-Power Macintoshes but does not copy properly on a Power Mac.
  296. > Both the srcRect and the DstRect are the same size ,Both PixMaps are 256 colors
  297. > and the transfer mode is SrcCpy.And it works on Non-Power Macs.
  298. > Has anybody out there have an inkling of what could cause the Copybits
  299. > routine to differ between Non power Macs and Power Macs.
  300.  
  301. Well, using CopyBits from/to GWorlds are supposed to be done by 
  302. dereferencing and locking the handle you get from GetGWorldPixMap()... 
  303. not from dereferencing the GWorld Handle. Some people don't know that, 
  304. and it causes a lot of problems...What I mean is:
  305.  
  306. THE WRONG WAY (which can work sometimes but not always):
  307.  
  308. CopyBits (((CGrafPtr)pGWorld)->portPixMap,
  309.           ((CGrafPtr)pWindow)->portPixMap,
  310.            rSourceRect,
  311.            rDestRect,
  312.            srcCopy,
  313.            nil);
  314.  
  315. A BETTER WAY (leaving out error checking, etc.):
  316.  
  317. hGWorldPixMap = GetGWorldPixMap (pGWorld);
  318. LockPixels (hGWorldPixMap);
  319. CopyBits ( *hGWorldPixMap,
  320.           ((CGrafPtr)pWindow)->portPixMap,
  321.             rSourceRect,
  322.             rDestRect,
  323.             srcCopy,
  324.             nil);
  325. UnlockPixels (hGWorldPixMap);
  326.  
  327. ...just a suggestion...
  328.  
  329. --Dave
  330.  
  331. +++++++++++++++++++++++++++
  332.  
  333. >From Martin_Byrod@digit.se (Martin Byrod)
  334. Date: 26 Mar 1996 14:05:47 GMT
  335. Organization: Digit
  336.  
  337. I was fading down one graphic and 
  338. fading up another. I faded down all 256 colors, drew the new graphics, 
  339. and faded up to the new clut.
  340.  
  341. Please post to this newsgroup and tell me how you faded your graphics.
  342. I really need to learn how to do that!!!
  343.  
  344. thanx in advance, 
  345.  
  346. Martin
  347.  
  348. +++++++++++++++++++++++++++
  349.  
  350. >From carl.gustafson@ece.drexel.edu (Carl Gustafson)
  351. Date: Tue, 26 Mar 1996 08:45:44 -0500
  352. Organization: Imaging and Computer Vision Center, Drexel University
  353.  
  354. In article <Brewski-2303962352230001@c12.dial.twics.com>,
  355. Brewski@twics.com (Brian Sweeney) wrote:
  356.  
  357. > I have read the books,downloaded the technical notes from apple etc but
  358. I cannot
  359. > find the reason why my Copybits routine copying from a PixMap to a
  360. GWorld works
  361. > on Non-Power Macintoshes but does not copy properly on a Power Mac.
  362. > Both the srcRect and the DstRect are the same size ,Both PixMaps are 256
  363. colors
  364. > and the transfer mode is SrcCpy.And it works on Non-Power Macs.
  365. > Has anybody out there have an inkling of what could cause the Copybits
  366. > routine to differ between Non power Macs and Power Macs.
  367. > Better yet ,if anybody has a simple code snippet of copying a dummy pixmap
  368. > to a GWorld that works on a Power Mac I would be eternally grateful.
  369.  
  370. I was having problems copybitsing from GWorld to GWorld - it would result
  371. in a quick
  372. trip to Macsbug. Copy from GWorld to screen (PixMap) would run just fine.
  373. Never tried
  374. the reverse - the screen is just to display the image, and we always go
  375. from image
  376. data to screen, never the reverse. ANYWAY, I finally traced it down to not
  377. having a
  378. GrafPort or GWorld set, believe it or not. Once I made a call to
  379. SetGWorld, things
  380. worked fine.
  381.  
  382. FWIW, HTH, YMMV, ETC.
  383.  
  384. -- 
  385. Carl Gustafson
  386. Imaging and Computer Vision Center
  387. Drexel University, Philadelphia, Penna
  388. - ----------------------------------------------------------
  389. I don't speak for Drexel, and Drexel doesn't listen to me...
  390.  
  391. ---------------------------
  392.  
  393. >From at@neuro.psy.soton.ac.uk (Adriaan Tijsseling)
  394. Subject: Determining Memory Size Needed by GWorld
  395. Date: Mon, 25 Mar 1996 07:30:01 +0000
  396. Organization: Electronics and Computer Science, University of Southampton
  397.  
  398. Hi,
  399.  
  400. How can I determine how much memory a GWorld with a given width and height
  401. needs? It is useful to compare this to the amount of free memory in my app
  402. before I call NewGWorld.
  403.  
  404. If you know how, mail or post it,
  405.  
  406. Many thanks in advance,
  407.  
  408. Adriaan Tijsseling
  409.  
  410.  
  411.  
  412. ______________________________________________________________
  413.  
  414. Work:
  415.    Cognitive Sciences Centre
  416.    Department of Psychology
  417.    University of Southampton
  418.    United Kingdom
  419.  
  420. Homepages:
  421.    work: http://www.soton.ac.uk/~coglab/coglab
  422.    life: http://www.soton.ac.uk/~agt/
  423.  
  424. E-mail:
  425.    at@neuro.psy.soton.ac.uk
  426.    at@cogsci.ecs.soton.ac.uk
  427.    agt@oak.soton.ac.uk
  428. ______________________________________________________________
  429.  
  430. +++++++++++++++++++++++++++
  431.  
  432. >From pottier@drakkar.ens.fr (Francois Pottier)
  433. Date: 25 Mar 1996 14:58:07 GMT
  434. Organization: Ecole Normale Superieure, Paris
  435.  
  436. In article <at-2503960730010001@sm1.psy.soton.ac.uk>,
  437. Adriaan Tijsseling <at@neuro.psy.soton.ac.uk> wrote:
  438.  
  439. >How can I determine how much memory a GWorld with a given width and height
  440. >needs? It is useful to compare this to the amount of free memory in my app
  441. >before I call NewGWorld.
  442.  
  443. There is no way to determine it other than guessing. The main
  444. component of a GWorld is its pixmap, so compute an approximation of
  445. its size by multiplying depth, height and width. Then, as a rule of
  446. thumb, add 15K for color tables, inverse tables, graphics device and
  447. other mysterious more-or-less-documented stuff.
  448.  
  449. Anyway, you should check NewGWorld's return code and exit gracefully
  450. it it different from noErr. You don't need to check the result for
  451. nil; the rumor that NewGWorld might return noErr and nil is, as far as
  452. I know, a myth fed by Object Pascal programmers forgetting to call
  453. HLock(Self). Anyway, checking for nil can't hurt.
  454.  
  455. Also, you can ask NewGWorld to allocate the pixmap in the temporary
  456. memory zone by setting a flag. If you do that, only the auxiliary
  457. structures will be allocated in your heap.
  458.  
  459. Hope this helps,
  460.  
  461.  
  462. -- 
  463. Francois Pottier
  464. Francois.Pottier@ens.fr
  465. Francois.Pottier@inria.fr
  466. http://www.eleves.ens.fr:8080/home/pottier/
  467.  
  468. +++++++++++++++++++++++++++
  469.  
  470. >From cameron_esfahani@powertalk.apple.com (Cameron Esfahani)
  471. Date: Tue, 26 Mar 1996 08:28:11 GMT
  472. Organization: Apple Computer, Inc.
  473.  
  474. Actually, a good idea is to nil out your gworldptr you pass to NewGWorld
  475. and if you don't get an error from NewGWorld compare compare the returned
  476. gworldptr to nil.  There are some error cases in NewGWorld where Quickdraw
  477. will bail out without returning an error.
  478.  
  479. Cameron Esfahani
  480.  
  481.  
  482. ---------------------------
  483.  
  484. >From fettig@cloister (Thomas Fettig)
  485. Subject: Direct-Optimized Access to PixMap
  486. Date: 23 Mar 1996 15:03:48 GMT
  487. Organization: DFKI - German Research Center for Artificial Intelligence
  488.  
  489.  
  490. Hello experts,
  491.  
  492. I am looking for information on how to manipulate the
  493. PixMap of an Offscreen GWorld directly. What i have is
  494. a piece of memory containing image data in 256 colors.
  495. When i construct the Pixmap by going through SetPixel,
  496. large images take a few seconds to convert. This seems
  497. to much to me. How may i access the PixMap in a 
  498. system-conforming way? (ie. Byte offsets, color values, etc)
  499. A pointer to a book or source-code would be fine too!
  500.  
  501. tia,
  502.         tom
  503.  
  504. +++++++++++++++++++++++++++
  505.  
  506. >From bzuk@telerama.lm.com (Brian Zuk)
  507. Date: Sat, 23 Mar 1996 17:10:19 -0500
  508. Organization: Telerama Public Access Internet, Pittsburgh, PA
  509.  
  510. In article <FETTIG.96Mar23160348@cloister>, fettig@cl.dfki.uni-sb.de wrote:
  511.  
  512. >Hello experts,
  513. >
  514. >I am looking for information on how to manipulate the
  515. >PixMap of an Offscreen GWorld directly. What i have is
  516. >a piece of memory containing image data in 256 colors.
  517. >When i construct the Pixmap by going through SetPixel,
  518. >large images take a few seconds to convert. This seems
  519. >to much to me. How may i access the PixMap in a 
  520. >system-conforming way? (ie. Byte offsets, color values, etc)
  521. >A pointer to a book or source-code would be fine too!
  522. >
  523. >tia,
  524. >        tom
  525.  
  526. Tom,
  527.   The safest/easiest approach for you is to construct a PixMapHandle that
  528. matches your cached data.  Then call CopyBits using the built PixMapHandle
  529. as the source and the GWorld as the dest pixMaps.
  530.   If you really want to move the data directly into the GWorld, you can
  531. copy bytes of information from one PixMap to the other by getting the base
  532. address from both of the pixMaps, determining how many bytes to move, and
  533. then moving them using a loop or BlockMove.  Any game programming book
  534. will have specific details of how to do this.
  535.   Feel free to e-mail me directly for any specific information.
  536.  
  537. Brian Zuk
  538.  
  539. +++++++++++++++++++++++++++
  540.  
  541. >From oo@oo.com (lisa beaufort)
  542. Date: 24 Mar 1996 04:41:38 GMT
  543. Organization: ooo
  544.  
  545. In article <FETTIG.96Mar23160348@cloister>, fettig@cl.dfki.uni-sb.de wrote:
  546.  
  547. > Hello experts,
  548. > I am looking for information on how to manipulate the
  549. > PixMap of an Offscreen GWorld directly. What i have is
  550. > a piece of memory containing image data in 256 colors.
  551. > When i construct the Pixmap by going through SetPixel,
  552. > large images take a few seconds to convert. This seems
  553. > to much to me. How may i access the PixMap in a 
  554. > system-conforming way? (ie. Byte offsets, color values, etc)
  555. > A pointer to a book or source-code would be fine too!
  556. > tia,
  557. >         tom
  558.  
  559. I can post some Assembly examples?
  560. c. lisa b.
  561.  
  562. +++++++++++++++++++++++++++
  563.  
  564. >From carl.gustafson@ece.drexel.edu (Carl Gustafson)
  565. Date: Tue, 26 Mar 1996 09:14:14 -0500
  566. Organization: Imaging and Computer Vision Center, Drexel University
  567.  
  568. In article <FETTIG.96Mar23160348@cloister>, fettig@cl.dfki.uni-sb.de wrote:
  569.  
  570. > I am looking for information on how to manipulate the
  571. > PixMap of an Offscreen GWorld directly. What i have is
  572. > a piece of memory containing image data in 256 colors.
  573. > When i construct the Pixmap by going through SetPixel,
  574. > large images take a few seconds to convert. This seems
  575. > to much to me. How may i access the PixMap in a 
  576. > system-conforming way? (ie. Byte offsets, color values, etc)
  577. > A pointer to a book or source-code would be fine too!
  578.  
  579.  
  580. Get a copy of the PixMapHandle from your GWorld, then extract the rowBytes
  581. field. Strip the high two bits to give you width (row spacing) of the 
  582. pixel image. Then call LockPixels (), and get the base address using
  583. GetPixBaseAddr (). You can now directly address the pixels in your GWorld
  584. by computing offsets from the base address. Be sure to use long math!
  585.  
  586.  
  587.  
  588.  
  589.       long           h,v,offset,width,height;
  590.       short          rowBytes;
  591.       unsigned char  *pixBase, pixel;
  592.  
  593.    rowBytes = (**thePixMap).rowBytes & 0x3FFF;
  594.    LockPixels (thePixMap);
  595.    pixBase = (unsigned char *) GetPixBaseAddr (thePixMap);
  596.    width = (**thePixMap).bounds.right - (**thePixMap).bounds.left;
  597.    width = (**thePixMap).bounds.bottom - (**thePixMap).bounds.top;
  598.    
  599.    for (v = 0; v < height; v++)
  600.    {
  601.       offset = v * rowBytes;
  602.       for (h = 0; h < width; h++)
  603.       {
  604.          pixel = *(pixBase + offset + h);
  605.          ...
  606.          etc
  607.          ...
  608.       }
  609.    }
  610.  
  611. -- 
  612. Carl Gustafson
  613. Imaging and Computer Vision Center
  614. Drexel University, Philadelphia, Penna
  615. - ----------------------------------------------------------
  616. I don't speak for Drexel, and Drexel doesn't listen to me...
  617.  
  618. ---------------------------
  619.  
  620. >From matthewf@panix.com (Matthew)
  621. Subject: Display Manager
  622. Date: Mon, 25 Mar 1996 09:40:52 -0500
  623. Organization: PANIX Public Access Internet and Unix, NYC
  624.  
  625. I seem to remember someone posting that DM will handle removing and
  626. restoring the menubar for game programmers who want to write to the full
  627. screen and still be compatable with future Macs.  But now I cant find any
  628. info on this in the DM Developer Notes, so I might have imagined this.
  629.  
  630. If anyone knows if this is true or not please let me know.
  631.  
  632. thanks
  633.  
  634. Matthew
  635.  
  636. +++++++++++++++++++++++++++
  637.  
  638. >From Maf Vosburgh <maf@mmcorp.com>
  639. Date: 25 Mar 1996 18:14:10 GMT
  640. Organization: MultiMedia Corporation plc
  641.  
  642. In article <matthewf-2503960940530001@matthewf.dialup.access.net>
  643. Matthew, matthewf@panix.com writes:
  644. >I seem to remember someone posting that DM will handle removing and
  645. >restoring the menubar for game programmers who want to write to the full
  646. >screen and still be compatable with future Macs.  But now I cant find any
  647. >info on this in the DM Developer Notes, so I might have imagined this.
  648. >
  649.  
  650. This is handled by a couple of QuickTime 2.1 calls, BeginFullScreen and
  651. EndFullScreen.
  652. It's a very nice simle API. It will do screen resolution switching for
  653. you as well.
  654.  
  655. The Display Manager is a real dog  - there are various different version
  656. to worry about, and the complex inter-connected data structures and
  657. callback procs will make your head spin.
  658.  
  659.  
  660. Maf
  661.  
  662. +++++++++++++++++++++++++++
  663.  
  664. >From dalawren@netcom.com (David Lawrence)
  665. Date: Sat, 30 Mar 1996 13:12:25 GMT
  666. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  667.  
  668. In article <matthewf-2503960940530001@matthewf.dialup.access.net>,
  669. matthewf@panix.com (Matthew) wrote:
  670.  
  671. > I seem to remember someone posting that DM will handle removing and
  672. > restoring the menubar for game programmers who want to write to the full
  673. > screen and still be compatable with future Macs.  But now I cant find any
  674. > info on this in the DM Developer Notes, so I might have imagined this.
  675. > If anyone knows if this is true or not please let me know.
  676.  
  677.  
  678.  
  679. There is a pair of QuickTime 2.1 calls - BeginFullScreen() and
  680. EndFullScreen() that will switch to a requested monitor resolution (if
  681. possible), hide the menu bar, and create a full screen window.  I believe
  682. it uses Display Manager 2.0 to switch resolutions - it won't switch if DM
  683. 2.0 is not installed.  Menu bar hiding is not part of Display Manager.
  684.  
  685.  
  686.    David Lawrence
  687.    Future Tense
  688.  
  689. ---------------------------
  690.  
  691. >From srharris@tucson.princeton.edu (Scott R. Harris)
  692. Subject: Fast writes to disk?
  693. Date: 5 Mar 1996 03:41:05 GMT
  694. Organization: Princeton University
  695.  
  696.  
  697. I've got a scientific frame grabber installed in my powermac 7500 and I want to
  698. capture 640x480x8 bit images and save them to disk as quickly as possible.
  699. What's the fastest way to write the data to the disk?  I tried using fopen and
  700. fwrite and i can get about 700K per second, but I want to go faster.  Are the
  701. macOS file routines faster (I'm going to try them tonight)?
  702.  
  703. Will an AV drive make a difference (I have the 1 gig drive that came with the
  704. computer)?  Are there lower level routines that are faster?  Will speed 
  705. doubler help?  What about cache?  I've also thought about using quicktime to 
  706. compress my images first, hopefully the time a i spend compressing will be 
  707. made up for in the time i spend writing to disk.
  708.  
  709. Anyhow, If I can get a sustained rate of about 3 Meg/second, I can do my 
  710. experiment in a really elegant way.
  711.  
  712. Thanks for any help,
  713. -Scott Harris
  714. Department of Mechanical and Aerospace Engineering, Princeton University
  715.    
  716.  
  717.  
  718.  
  719. +++++++++++++++++++++++++++
  720.  
  721. >From grinch@buffnet.net (The Grinch)
  722. Date: 6 Mar 1996 20:23:35 GMT
  723. Organization: Vortex Software
  724.  
  725. In article <4hgd4h$3qh@cnn.Princeton.EDU>, srharris@tucson.princeton.edu
  726. (Scott R. Harris) wrote:
  727.  
  728. > I've got a scientific frame grabber installed in my powermac 7500 and I
  729. want to
  730. > capture 640x480x8 bit images and save them to disk as quickly as possible.
  731. > What's the fastest way to write the data to the disk?  I tried using fopen and
  732. > fwrite and i can get about 700K per second, but I want to go faster.  Are the
  733. > macOS file routines faster (I'm going to try them tonight)?
  734.  
  735. I don't think lower level routines would be appreciably faster. (I mean,
  736. how much CPU time does glue code really eat?) Using a faster HD is an
  737. obvious choice, though. How much RAM have you got? Fair amount? Then why
  738. not make a huge RAM disk and write to that? In an ideal situation, I'd get
  739. my hands on a big ol' RAID 0 array, but that's not often feasible. Anyway,
  740. that's just my 2¢. Good luck!
  741.  
  742. -The Grinch
  743.  
  744. +++++++++++++++++++++++++++
  745.  
  746. >From slasley@space.umd.edu (Scott E. Lasley)
  747. Date: Fri,  8 Mar 1996 18:13:51 -0500
  748. Organization: UMD Space Physics Group
  749.  
  750. In article <4hgd4h$3qh@cnn.Princeton.EDU>, srharris@tucson.princeton.edu 
  751. (Scott R. Harris) writes:
  752. > I've got a scientific frame grabber installed in my powermac 7500 and 
  753. > I want to capture 640x480x8 bit images and save them to disk as quickly 
  754. > as possible. 
  755. > What's the fastest way to write the data to the disk?  I tried using 
  756. > fopen and fwrite and i can get about 700K per second, but I want to 
  757. > go faster.  Are the macOS file routines faster (I'm going to try 
  758. > them tonight)? 
  759. >  
  760.  
  761. tech note FL 16 - File Manager Performance and Caching - contains a lot of 
  762. good information about getting the most out of the file manager
  763.  
  764. http://dev.info.apple.com/technotes/Archive/Files/fl_16.html
  765.  
  766. one source of good file i/o code is the MoreFiles package at
  767.  
  768. <ftp://members.aol.com//JumpLong/>
  769.  
  770. hope this helps,
  771.  
  772.  
  773. scott lasley   slasley@space.umd.edu, http://space.umd.edu
  774. "Cheating is bad.  Richard Basehart is good."  MST3K
  775. http://fermi.clas.virginia.edu/~jcp9j/canceled.html
  776.  
  777.  
  778. +++++++++++++++++++++++++++
  779.  
  780. >From blob@ccnet.com
  781. Date: Sun, 17 Mar 1996 11:55:04 -0800
  782. Organization: CCnet Communications (510-988-7140 guest)
  783.  
  784. In article <4hgd4h$3qh@cnn.Princeton.EDU>, srharris@tucson.princeton.edu
  785. (Scott R. Harris) wrote:
  786.  
  787. > I've got a scientific frame grabber installed in my powermac 7500 and I
  788. want to
  789. > capture 640x480x8 bit images and save them to disk as quickly as possible.
  790. > What's the fastest way to write the data to the disk?  I tried using fopen and
  791. > fwrite and i can get about 700K per second, but I want to go faster.  Are the
  792. > macOS file routines faster (I'm going to try them tonight)?
  793.  
  794. Read tech note FL 16, at
  795. <http://dev.info.apple.com/technotes/Archive/Files/fl_16.html>
  796.  
  797. It's all about file system performance.  Basically, keep your buffers as
  798. large as possible, use the cache wisely, bypass the cache when it makes
  799. sense.
  800.  
  801. fopen and fwrite have buffers determined by your standard i/o library.  I
  802. doubt if they are optimized.  Look at MoreFiles for better examples of
  803. fast writes.
  804.  
  805.  
  806. +++++++++++++++++++++++++++
  807.  
  808. >From tonyn@tiac.net (Tony Nelson)
  809. Date: Sat, 23 Mar 1996 22:14:55 -0500
  810. Organization: The Internet Access Company
  811.  
  812. In article <blob-1703961155040001@h108-5-129.ccnet.com>, blob@ccnet.com wrote:
  813.  
  814. > ... Basically, keep your buffers as
  815. > large as possible ...
  816.  
  817. There have been some reports of problems if the reads or writes are for
  818. more than about 1 or 2 MB at a time, with some Macs and some hard disk
  819. drivers.  I would guess that there is some sort of diminishing return
  820. about 64..256K, so if you want you could avoid those possible problems.
  821.  
  822. You want to use async I/O.  On older Macs it won't help, but new ones
  823. should get a big performance boost as you can be grabbing and storing
  824. simultaneously.
  825. ____________________________________________________________________
  826. TonyN.:'                                              tonyn@tiac.net
  827.       '
  828.  
  829. +++++++++++++++++++++++++++
  830.  
  831. >From jumplong@aol.com (Jump Long)
  832. Date: 24 Mar 1996 14:04:49 -0500
  833. Organization: America Online, Inc. (1-800-827-6364)
  834.  
  835. Tony Nelson wrote:
  836. >There have been some reports of problems if the reads or writes
  837. >are for more than about 1 or 2 MB at a time, with some Macs and
  838. >some hard disk drivers.  I would guess that there is some sort
  839. >of diminishing return about 64..256K, so if you want you could
  840. >avoid those possible problems.
  841.  
  842. Most of those problems are due to disk drivers not handling VM issues
  843. correctly. However, Tony is correct that at some point, increasing the
  844. size of your I/O operations gives very little performance gains. With
  845. faster hard disks, that point is a smaller amount than with slower media
  846. (floppy disks, CD-ROMs, etc.).
  847.  
  848. >You want to use async I/O.  On older Macs it won't help, but new
  849. >ones should get a big performance boost as you can be grabbing
  850. >and storing simultaneously.
  851.  
  852. Since the File Manager is single-threaded (for the most part), multiple
  853. async requests just execute in the order they are added the File Manager's
  854. queue. If the device you're using supports async I/O operations, then
  855. doing other non-I/O related tasks while waiting for the async requests to
  856. complete is what really gives the most wins today. For example, the System
  857. 7.5.2 and 7.5.3 Finder uses async reads and writes for file copy
  858. operations and then calls WaitNextEvent while waiting for the requests to
  859. complete. This allows the user to perform non-I/O tasks with other
  860. applications while the Finder is copying files.
  861.  
  862. - Jim Luther
  863.  
  864. jumplong@aol.com
  865. <http://members.aol.com/JumpLong/>
  866.  
  867. ---------------------------
  868.  
  869. >From v.salupo@lilly.com (Vince Salupo)
  870. Subject: How should data be organized for read-write to files?(beginner)
  871. Date: Tue, 26 Mar 1996 15:04:46 -0500
  872. Organization: Eli Lilly and Company
  873.  
  874. Most Mac programming books deal with interface issues. I haven't run across a
  875. clear explanation of how to do any of the following in C:
  876.  
  877. - create structures that are most efficient for writing/reading to a file
  878.   (BTW- what is struct alignment?)
  879.  
  880. - preparing data for reading and writing
  881.  
  882. - managing data that isn't saved yet
  883.  
  884. - implementing an "Undo" scheme
  885.  
  886. I have lots of source code to look at, but references to any develop or MacTech
  887. articles on the subject would be greatly appreciated. Is any of this in
  888. the Inside Mac volumes? I have been browsing the Files volume without
  889. finding anything that looks like it answers my questions.
  890.  
  891.  
  892. Any help appreciated
  893.  
  894. Vincent P Salupo
  895. Eli Lilly and Company
  896. v.salupo@lilly.com
  897. As usual: All opinions are mine and do not reflect the views of my
  898.           Company, Managers, co-workers, spouse, children, dog    
  899.           etc.... 
  900.  
  901.  
  902. +++++++++++++++++++++++++++
  903.  
  904. >From woody@alumni.caltech.edu (William Edward Woody)
  905. Date: 27 Mar 1996 01:53:20 GMT
  906. Organization: In Phase Consulting
  907.  
  908. v.salupo@lilly.com (Vince Salupo) wrote:
  909.  
  910. > Most Mac programming books deal with interface issues. I haven't run across a
  911. > clear explanation of how to do any of the following in C:
  912. > - create structures that are most efficient for writing/reading to a file
  913.  
  914. The Macintosh is happiest reading and writing large blocks of data to
  915. and from a file. If you are storing your file as a series of structures,
  916. and you are writing those structures directly to disk (using FSRead/FSWrite),
  917. then just about any alignment is going to be relatively inefficient.
  918.  
  919. It's a tradeoff here--do you want the fastest read/write time possible?
  920. Or do you want a simle solution which is fast enough and easy to maintain?
  921. I'd suggest the latter.
  922.  
  923. >   (BTW- what is struct alignment?)
  924.  
  925. The elements in a structure are aligned to certain rules in order to
  926. maintain efficient access to the elements of those structures. This
  927. alignment is done by padding your structures with empty space, according
  928. to some simple rules, depending on the alignment.
  929.  
  930. The most common alignment is the 68K 2-byte alignment rules. These
  931. rules were first developed because the 68000 processor is unable to
  932. read 2-byte or 4-byte data objects which are aligned on an odd byte.
  933. Compilers align this data by padding the data to make shorts and longs
  934. land on even byte boundaries.
  935.  
  936. Thus, a structure:
  937.  
  938.         struct {
  939.                 char    byte1;
  940.                 short   word1;
  941.                 char    byte2;
  942.                 short   word2;
  943.         } s;
  944.  
  945. would be aligned:
  946.  
  947.         offset          data
  948.           0             byte    byte1
  949.           1             byte    (padding)
  950.           2             word    word1
  951.           4             byte    byte2
  952.           5             byte    (padding)
  953.           6             word    word2
  954.  
  955. Notice that two bytes of padding are added, one after 'byte1' and one
  956. after 'byte2'; this causes the data that follows to be word-aligned.
  957. Now if arranged the structure to be:
  958.  
  959.         struct {
  960.                 char    byte1;
  961.                 char    byte2;
  962.                 short   word1;
  963.                 short   word2;
  964.         };
  965.  
  966. then our alignments are:
  967.  
  968.         offset          data
  969.           0             byte    byte1
  970.           1             byte    byte2
  971.           2             word    word1
  972.           4             word    word2
  973.  
  974. Notice that as the byte sized objects do not have to be word aligned
  975. (only 2 and 4 byte, and larger, objects), the byte sized object 'byte2'
  976. can be placed at offset 1.
  977.  
  978. This has the side effect that the structure is two bytes smaller, by the
  979. way.
  980.  
  981. Different rules exist; there is a 4-byte alignment (where objects are
  982. aligned to 4 byte boundaries instead of two byte boundaries), and PowerPC
  983. alignment (where objects are aligned to be on the boundary that reflects
  984. the object's size), but I am not really sure how they work.
  985.  
  986. > - preparing data for reading and writing
  987.  
  988. It depends on the internal structures you are using for your application.
  989.  
  990. As a general rule, I tend to simply write out a copy of my internal
  991. data structures in a format which makes it easy to reconstruct my
  992. internal data structures from the file.
  993.  
  994. I do this by first writing a header to the file which is a structure
  995. which contains the version number of this file. (Just in case I change
  996. my internal structures, and hense the format of the file.)
  997.  
  998. Then I walk my different data structures, writing out my structures,
  999. along with some information as to what that structure is.
  1000.  
  1001. One method I sometimes use is to write out 'tags'; each 'tag' is a
  1002. simple structure:
  1003.  
  1004.         struct {
  1005.                 short   type;
  1006.                 long    offset;
  1007.         };
  1008.  
  1009. where 'type' is an integer which I assign to my different internal
  1010. structures, and 'offset' is the offset to the next tag in the file.
  1011.  
  1012. This has several advantages. First, you can skip types which you don't
  1013. understand, allowing you to add information to later versions of the file
  1014. which can be read by earlier versions of your program.
  1015.  
  1016. Second, you can nest tags; the offset in each nesting would point to the
  1017. next associated tags, but the data that follows can also contain tags.
  1018.  
  1019. Third, if you assign version information to your tags (such as the number
  1020. of bytes you think you need to write out your structure), you can add
  1021. new fields to the end of your structure. Then, when you read the data
  1022. in, if the data following the tag is larger than your structure, simply
  1023. ignore it. This also allows later versions of your software to be able
  1024. to write files readable by earlier versions of your software.
  1025.  
  1026. > - managing data that isn't saved yet
  1027.  
  1028. That's easy--at every entry point which can modify your data, call a function
  1029. which flips a 'dirty' bit. This 'dirty' bit then indicates if your data
  1030. needs to be saved; this allows you to take the appropriate action where
  1031. needed.
  1032.  
  1033. > - implementing an "Undo" scheme
  1034.  
  1035. Undo is difficult.
  1036.  
  1037. There are three schemes for doing 'Undo' which I know about.
  1038.  
  1039. The first scheme is good for small databases--simply preserve a copy of
  1040. the unedited database along with the edited version. Then, when the
  1041. user requests the 'undo' function, swap the databases.
  1042.  
  1043. For example, suppose you are able to store all of your database in a
  1044. single Macintosh handle. Then, when an editing procedure takes place,
  1045. you do the following steps:
  1046.  
  1047.         1)  Update the dirty flag.
  1048.         2)  Delete the old 'undo' handle.
  1049.         3)  Make a copy of your database handle and store it in the undo
  1050.             handle holder.
  1051.         4)  Modify your database.
  1052.  
  1053. When you undo, then swap the current with the undo database.
  1054.  
  1055.  
  1056. The second scheme is a bit more difficult, but uses far less memory.
  1057. It works well with drawing programs, but can also be made to work with
  1058. a text editor.
  1059.  
  1060. When an edit takes place, you create a record which stores the actions
  1061. that are taken to perform that edit. For example, suppose you draw a new
  1062. line. Then your edit record contains the 'add line' command, and the
  1063. coordinates of that line.
  1064.  
  1065. Then, you keep the last edit record in your 'undo' pointer. This allows
  1066. you to know what you changed the last time the user edited the file.
  1067. Then, when it comes time to undo the file, you can look at the 'last
  1068. edit' record, and reverse it's actions.
  1069.  
  1070. You can extend this idea to multiple undos and multiple redos; just
  1071. keep the last 10 or 20-odd edit records.
  1072.  
  1073.  
  1074. The third scheme is a variant of the second. It involves applying the
  1075. editing records on the fly to the database to represent the final
  1076. editing product.
  1077.  
  1078. Assume you have a routine, call it 'GetCurrentState'. This routine
  1079. would normally return your database so you can display it and the
  1080. like. Instead of preserving your 'edit' states to the database,
  1081. and keeping around the changed database, you instead keep around
  1082. the _unchanged_ database, and have your 'GetCurrentState' apply
  1083. the edits to the database on the fly.
  1084.  
  1085. This works very well for thinks like drawing programs: if you have a
  1086. routine, 'GetNumberOfObjects' which returns the number of lines, circles,
  1087. and the like, then this routine would be modified to look through
  1088. the list of edit records, counting the number of objects that were
  1089. inserted or deleted, to find the final number of objects to display.
  1090. Another routine, 'GetObjectByIndex' would return the appropriate
  1091. object, either from the edit record, or from the orignal database,
  1092. of the line, circle, or other object to process.
  1093.  
  1094. This has the advantage that if you can optimize the database access
  1095. routines (like in a drawing program), your editing and undo process
  1096. becomes simple--simply add a new edit record to the list of edit
  1097. records. Undoing is removing the last edit, and updating the display.
  1098.  
  1099. > Any help appreciated
  1100.  
  1101. I hope this helps.
  1102.  
  1103.                                                 - Bill
  1104.  
  1105. -- 
  1106. William Edward Woody  |  e-mail: woody@alumni.cco.caltech.edu
  1107. In Phase Consulting   |  WWW:    http://www.alumni.caltech.edu/~woody
  1108. 337 W. California #4  |  Fax:    (818) 502-1467
  1109. Glendale, CA 91203    |  ICBM:   N:34.15' W:118.25'
  1110.  
  1111. +++++++++++++++++++++++++++
  1112.  
  1113. >From jumplong@aol.com (Jump Long)
  1114. Date: 27 Mar 1996 02:05:34 -0500
  1115. Organization: America Online, Inc. (1-800-827-6364)
  1116.  
  1117. >Most Mac programming books deal with interface issues. I haven't
  1118. >run across a clear explanation of how to do any of the following
  1119. >in C:
  1120. >
  1121. >- create structures that are most efficient for writing/reading
  1122. >to a file
  1123. >  (BTW- what is struct alignment?)
  1124. >
  1125. >- preparing data for reading and writing
  1126. >
  1127. >- managing data that isn't saved yet
  1128. >
  1129. >- implementing an "Undo" scheme
  1130. >
  1131. >I have lots of source code to look at, but references to any
  1132. >develop or MacTech articles on the subject would be greatly
  1133. >appreciated. Is any of this in the Inside Mac volumes? I have
  1134. >been browsing the Files volume without finding anything that
  1135. >looks like it answers my questions.
  1136.  
  1137. Some of the advice you're looking for can be found in a Technical Note I
  1138. wrote "FL16 - File Manager Performance and Caching"
  1139. <http://dev.info.apple.com/technotes/Archive/Files/fl_16.html>
  1140.  
  1141. - Jim Luther
  1142.  
  1143. ---------------------------
  1144.  
  1145. >From nordic@inetnebr.com (Dave)
  1146. Subject: How to Do Registration Codes
  1147. Date: Thu, 14 Mar 1996 13:47:05 -0600
  1148. Organization: Internet Nebraska
  1149.  
  1150. Does anyone have any pointers on how to program registration codes?  I
  1151. know how to do the dialogs and all of the general programming.  My
  1152. question is how to set up a system where specific codes will unlock the
  1153. program.
  1154.  
  1155.  
  1156. Thanks
  1157. Dave
  1158. ============================================================================
  1159. Nordic Software Inc.  - dedicated to educational software since 1986
  1160. P.O. Box 6007           Phone: (402) 488 - 5086
  1161. Lincoln, NE 68506       Fax:   (402) 488 - 2914
  1162. - ---------------------------------------------
  1163. E-Mail info@nordicsoftware.com
  1164.  
  1165. Free educational software drawing on our web page each week!
  1166. http://www.nordicsoftware.com/
  1167. ============================================================================
  1168.  
  1169. +++++++++++++++++++++++++++
  1170.  
  1171. >From jim@bogie2.bio.purdue.edu (Jim Cavera)
  1172. Date: Thu, 14 Mar 1996 18:37:35 -0500
  1173. Organization: Purdue University
  1174.  
  1175. > Does anyone have any pointers on how to program registration codes?  I
  1176. > know how to do the dialogs and all of the general programming.  My
  1177. > question is how to set up a system where specific codes will unlock the
  1178. > program.
  1179.  
  1180. My personal method:
  1181.  
  1182.    The resource fork of your program will contain a you-defined resource
  1183.    that consists of a single stream of characters, say 10-long like this:
  1184.  
  1185.             fz93e1n43a
  1186.  
  1187.    Your program looks for this on start-up. If it's missing, ExitToShell().
  1188.    The user must enter they're registration code, also 10-digits like this:
  1189.  
  1190.             36fizamc9q
  1191.  
  1192.    This also gets files away in a different resource in the prefs file.  If
  1193.    the first resource is present, but the second one is missing, prompt the
  1194.    user to enter they're registration code.  You get the idea.
  1195.  
  1196.    Now then, when your app starts up, it fetches the code from its res fork
  1197.    and the user's registration code from the prefs file.  It adds them
  1198.    together on a character by character basis.  It then subtracts a constant
  1199.    from each character.  It then compares the character array (c-string)
  1200.    that remains to a caracter array in the code.  If there are differences,
  1201.    it exits.  Thus you have :
  1202.  
  1203.             fz93e1n43a
  1204.          +  36fizamc9q
  1205.       -----------------
  1206.             **********     <---- some character garbage
  1207.          -  nnnnnnnnnn     <---- any arbitrary constant
  1208.       -----------------
  1209.             thissucks!     <---- a string to compare with the internal one
  1210.  
  1211. This method works well as you don't have to re-compile anything to give
  1212. each copy a unique identifier.  Though it's not ultra-secure by any stretch,
  1213. it seems to work very well.  Comments from the net?
  1214.  
  1215. - Jim Cavera (bit-pushing slave)
  1216. jim@bogie2.bio.purdue.edu
  1217.  
  1218. BTW:  I don't know how the "pros" do it -- this is just something I
  1219.       dreamed up on my own.  Take it with a mine of salt.
  1220.  
  1221. +++++++++++++++++++++++++++
  1222.  
  1223. >From flisakow@fontina.cs.wisc.edu (Shaun Flisakowski)
  1224. Date: 15 Mar 1996 08:11:22 GMT
  1225. Organization: U of Wisconsin CS Dept
  1226.  
  1227. In article <jim-1403961837350001@ibcrc3.bio.purdue.edu>,
  1228. Jim Cavera <jim@bogie2.bio.purdue.edu> wrote:
  1229. >> Does anyone have any pointers on how to program registration codes?  I
  1230. >> know how to do the dialogs and all of the general programming.  My
  1231. >> question is how to set up a system where specific codes will unlock the
  1232. >> program.
  1233. >
  1234. >My personal method:
  1235. >
  1236. [snip]
  1237. >
  1238. >            fz93e1n43a
  1239. >         +  36fizamc9q
  1240. >      -----------------
  1241. >            **********     <---- some character garbage
  1242. >         -  nnnnnnnnnn     <---- any arbitrary constant
  1243. >      -----------------
  1244. >            thissucks!     <---- a string to compare with the internal one
  1245.  
  1246.     I agree with the basic concept, but have a few things to add.
  1247.  
  1248.     You should not use literal strings in the code.  These are very
  1249.     easy for a cracker to locate.  Converting the strings to numbers,
  1250.     then using them is a much better plan.
  1251.  
  1252.     You should keep in mind that you don't want anything that can be
  1253.     easily "observed" via a debugger.  If the password string entered
  1254.     is decimated and scattered about, you're making life that much
  1255.     harder for a cracker.
  1256.  
  1257.     This is one place where modularity should be avoided, as well.
  1258.     The check can be spread out over many functions (place a comment
  1259.     by each part in your source to help you find them).
  1260.     This expands the area that must be disassembled/examined.
  1261.  
  1262.     If you can intertwine your registration check with another part
  1263.     of the software, all the better.  If the software is partially
  1264.     broken by being cracked, you have succeeded. 
  1265.  
  1266.     You might want to try cracking a product; if you're sucessful,
  1267.     ask yourself what the programmer could have done to make it more
  1268.     difficult.
  1269.  
  1270. -- 
  1271.     Shaun        flisakow@cs.wisc.edu
  1272.  
  1273.    "In your heart you know its flat."
  1274.                            -Flat Earth Society
  1275.  
  1276. +++++++++++++++++++++++++++
  1277.  
  1278. >From gumboot@airdmhor.gen.nz (Simon Hosie)
  1279. Date: 17 Mar 1996 00:58:24 +1300
  1280. Organization: Airdmhor : a couple of BBS's, a bunch of people, and a cat.
  1281.  
  1282. Shaun Flisakowski:
  1283. >     If you can intertwine your registration check with another part
  1284. >     of the software, all the better.  If the software is partially
  1285. >     broken by being cracked, you have succeeded. 
  1286.  
  1287. >     You might want to try cracking a product; if you're sucessful,
  1288. >     ask yourself what the programmer could have done to make it more
  1289. >     difficult.
  1290.  
  1291.   The problem is that all the really good methods for keeping people out of
  1292. your code are completely system unfriendly..
  1293.  
  1294.   The best thing I can think of is to interpret your own instruction set
  1295. which is decoded by the interpreter using a seed you give it as a
  1296. registration number of some sort..  The problem there is getting that number
  1297. to be different from machine to machine - otherwise one person can register
  1298. their copy and that of everyone they know..
  1299.  
  1300. +++++++++++++++++++++++++++
  1301.  
  1302. >From avg@xs4all.nl (Arno van Goch)
  1303. Date: Sat, 16 Mar 1996 15:02:23 GMT
  1304. Organization: XS4ALL, networking for the masses
  1305.  
  1306. nordic@inetnebr.com (Dave) wrote:
  1307.  
  1308. >Does anyone have any pointers on how to program registration codes?  I
  1309. >know how to do the dialogs and all of the general programming.  My
  1310. >question is how to set up a system where specific codes will unlock the
  1311. >program.
  1312. You should make registration codes that hold all the information you
  1313. want *plus* a checksum.  The checksum is important because it makes
  1314. sure that not any random code is accepted as a valid registration
  1315. code.
  1316.  
  1317. An older version of a well known commercial program had codes like 
  1318.  56242363-31 
  1319. Where '56242363' was the serial number, and '31' the sum of all the
  1320. numbers that make up the serial number.
  1321. So a code 56242363-32 would not be accepted.
  1322.  
  1323. To disguise the algorithm better codes could be written as 5624236331
  1324. (leaving away the '-' ).  Or mangle those numbers in a specific way
  1325. like 3235614236. 
  1326.  
  1327. In a program of mine I wanted registration in the following form.
  1328.  
  1329. Registration name : ...
  1330. Registration code : ...
  1331.  
  1332. The registration code should only work with a valid registration name.
  1333. This makes it clear for the registered users that they can give their
  1334. codes away to friends, but not without leaving their name in the
  1335. pirated version.
  1336.  
  1337. The registration code should therefore hold the following information
  1338. :
  1339. -Serial number
  1340. -Checksum of registration name
  1341. -Checksum of the registration code
  1342.  
  1343. I decided how many bits I wanted to use for each. Checksums were
  1344. mostly done with XOR operations. The checksum of the registration code
  1345. was calculated something like (Serialnumber) XOR (Name checksum) XOR
  1346. (constant). The constant is a fixed value that indicates the
  1347. application. I could therefore use the same algorithm for a different
  1348. program by just changing this constant. 
  1349.  
  1350. As a bones all the resulting bits were mangled and  converted to an
  1351. 'ASCII' notation.
  1352.  
  1353. Other things to consider : 
  1354. -A not-too-strict calculation of the name-checksum. Allow some typos
  1355. and make it case insensitive
  1356. -While Converting from bits->ASCII try to avoid characters that could
  1357. cause mistakes like 0 or O, 1 of l.
  1358.  
  1359. -- Arno van Goch --
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365. +++++++++++++++++++++++++++
  1366.  
  1367. >From Larry Hotchkiss <wcdc@winternet.com>
  1368. Date: Sat, 16 Mar 1996 12:23:27 -0600
  1369. Organization: StarNet Communications, Inc
  1370.  
  1371. Simon Hosie wrote:
  1372. > Shaun Flisakowski:
  1373. > >     If you can intertwine your registration check with another part
  1374. > >     of the software, all the better.  If the software is partially
  1375. > >     broken by being cracked, you have succeeded.
  1376. > >     You might want to try cracking a product; if you're sucessful,
  1377. > >     ask yourself what the programmer could have done to make it more
  1378. > >     difficult.
  1379. >   The problem is that all the really good methods for keeping people out of
  1380. > your code are completely system unfriendly..
  1381. >   The best thing I can think of is to interpret your own instruction set
  1382. > which is decoded by the interpreter using a seed you give it as a
  1383. > registration number of some sort..  The problem there is getting that number
  1384. > to be different from machine to machine - otherwise one person can register
  1385. > their copy and that of everyone they know..
  1386.  
  1387.  
  1388.     How about using the volume serial number off their hard drive. 
  1389. The only problem I see hear is if thier system craches and they get a new 
  1390. drive they will need to get a new code to use it.
  1391. -- 
  1392.  
  1393.                         Larry H.
  1394.  
  1395. +++++++++++++++++++++++++++
  1396.  
  1397. >From haverber@winternet.com (Bill Haverberg)
  1398. Date: Sun, 17 Mar 1996 06:23:40 GMT
  1399. Organization: StarNet Communications, Inc
  1400.  
  1401. Larry Hotchkiss <wcdc@winternet.com> wrote:
  1402.  
  1403.  
  1404. >    How about using the volume serial number off their hard drive. 
  1405. >The only problem I see hear is if thier system craches and they get a new 
  1406. >drive they will need to get a new code to use it.
  1407. >-- 
  1408.  
  1409. I saw in the major access programming group that someone was offering
  1410. a free security dll that works with the volume serial number. My
  1411. system crashed and I lost track of it before I could get ahold of it,
  1412. but a polite request on the group should flush it out.
  1413.  
  1414.  
  1415.  
  1416. +++++++++++++++++++++++++++
  1417.  
  1418. >From Janet <dascalu@math.tau.ac.il>
  1419. Date: Tue, 19 Mar 96 19:44:58
  1420. Organization: NetVision LTD.
  1421.  
  1422.  
  1423. In Article<314B071F.1219@winternet.com>, <wcdc@winternet.com> writes:
  1424. > Simon Hosie wrote:
  1425. > > 
  1426. > > Shaun Flisakowski:
  1427. > > >     If you can intertwine your registration check with another part
  1428. > > >     of the software, all the better.  If the software is partially
  1429. > > >     broken by being cracked, you have succeeded.
  1430. > > 
  1431. > > >     You might want to try cracking a product; if you're sucessful,
  1432. > > >     ask yourself what the programmer could have done to make it more
  1433. > > >     difficult.
  1434. > > 
  1435. > >   The problem is that all the really good methods for keeping people out 
  1436. of
  1437. > > your code are completely system unfriendly..
  1438. > > 
  1439. > >   The best thing I can think of is to interpret your own instruction set
  1440. > > which is decoded by the interpreter using a seed you give it as a
  1441. > > registration number of some sort..  The problem there is getting that 
  1442. number
  1443. > > to be different from machine to machine - otherwise one person can 
  1444. register
  1445. > > their copy and that of everyone they know..
  1446. >     How about using the volume serial number off their hard drive. 
  1447. > The only problem I see hear is if thier system craches and they get a new 
  1448. > drive they will need to get a new code to use it.
  1449. > -- 
  1450. >             
  1451.  
  1452. why mess with this al all, do something simple, even if 
  1453. someone broke your protection and it is distrebuted like this, change the 
  1454. method to something else on the next version, if someone
  1455. doesn't want to pay for shareware HE WILLL NOT DO IT
  1456.  
  1457.  
  1458.  
  1459. +++++++++++++++++++++++++++
  1460.  
  1461. >From hsoi@tamu.edu (John C. Daub)
  1462. Date: 20 Mar 1996 04:57:48 GMT
  1463. Organization: Wish I Had More Of It
  1464.  
  1465.  
  1466. all of the registration methods here seem pretty good, but very complex.
  1467.  
  1468. i guess what to use to decide what choice to take would be just what
  1469. you were wanting in the end.  if a high security mechanism, maybe try
  1470. that robust 2 string-add-subtract-thissucks method (with the suggestions
  1471. that other guy gave to it).  but it's true, that could still be something
  1472. "traced" in workings via Macsbug (and other things) and if they see what
  1473. you're doing, you're sol.
  1474.  
  1475. but then, aside from PGP, what can't be cracked? :)
  1476.  
  1477. i thought of a simple technique the other day, and i wonder what people
  1478. think about it.  sure, it's NOT very robust, nor secure, but i'm more
  1479. interested in something that could be used to keep the majority of
  1480. the public (of shareware users) from features until they register.  like
  1481. if i had a demo version, the "serial number they obtain upon paying their
  1482. shareware fee" would totally unlock the program.
  1483.  
  1484. it's very simple...
  1485.  
  1486. create a pattern for your registration number.  like so many "characters"
  1487. (the more the merrier).  let's say we'll have 15 characters.
  1488.  
  1489.  
  1490. now, they could be anything, numbers, letters, maybe even other things
  1491. like !@#$%^&^&* or something :)
  1492.  
  1493. now, lay out a pattern (sorta like an FMAT in concept, on Macs).  oh, i just
  1494. realized this was cross posted to alt.comp.shareware.programmer, so sorry
  1495. for the mac references, but the concept can remain.
  1496.  
  1497. something like, 3 digits, hyphen, 2 digits, 2 letters, 2 digits hypen,
  1498. digit, letter, 2 digits.
  1499.  
  1500. so like:  123-45-AB67-8C90
  1501.  
  1502. then, you can check for this pattern in your registration dialog code.
  1503.  
  1504. get the string from the reg dialog, parse it byte by byte.  you can even
  1505. do another first check, if not "15" characaters long, reject it...if
  1506. it is 15, parse for the "type" of character...like for the first character,
  1507. if it's not a digit, reject.
  1508.  
  1509. and then you could do even more...say the third character had to be a digit
  1510. between 5 and 9 but not 6.  or 1 or 4 or 8 only.  or always R or something.
  1511.  
  1512. that could help to even make it more complex to get around.
  1513.  
  1514. and, if you use the reg code to keep track of things (like they're customer
  1515. number 50 to register, the type of computer they have, or whatever other
  1516. database/recordkeeping you might want to use), you could have your own
  1517. sort of "code" for all this built in there, y'know?  just gotta use the
  1518. imagination :)
  1519.  
  1520. and of course, the more cryptic you can make it to your user, probably
  1521. the better it is secruity wise.
  1522.  
  1523. of course, anyone with time and effort would eventually get through almost
  1524. anything, but perhaps this is a way to do it all "interally" without
  1525. resources or something.
  1526.  
  1527. oh, and a way to know if they've registered or not...upon startup, it's
  1528. doubtful they'd have a prefs file.  don't create one until after a successful
  1529. registration...or, have something in the prefs file (again, cryptic) to
  1530. note they've not registered yet.  again, not high security, but a fast,
  1531. cheap, easy method, IMHO.
  1532.  
  1533. any comments?
  1534.  
  1535. -- 
  1536. John C. Daub (aka Hsoi)   | <mailto:hsoi@tamu.edu>
  1537. Grad Student, Lab Manager | <http://http.tamu.edu:8000/~jcd7106/>
  1538. Self-proclaimed Mac Guru  | Department of Speech Communication
  1539. Will program for food.    | Texas A&M University, USA
  1540.  
  1541. "Ain't it funny how that money rots your brain?"  -COC
  1542.  
  1543. +++++++++++++++++++++++++++
  1544.  
  1545. >From troika@panix.com (Mark Coniglio)
  1546. Date: Thu, 21 Mar 1996 08:56:38 -0500
  1547. Organization: Troika Ranch
  1548.  
  1549. In article <hsoi-1903962303090001@ppp16-17.rns.tamu.edu>, hsoi@tamu.edu
  1550. (John C. Daub) wrote:
  1551.  
  1552. > something like, 3 digits, hyphen, 2 digits, 2 letters, 2 digits hypen,
  1553. > digit, letter, 2 digits.
  1554. > so like:  123-45-AB67-8C90
  1555. > then, you can check for this pattern in your registration dialog code.
  1556. > get the string from the reg dialog, parse it byte by byte.  you can even
  1557. > do another first check, if not "15" characaters long, reject it...if
  1558. > it is 15, parse for the "type" of character...like for the first character,
  1559. > if it's not a digit, reject.
  1560. > and then you could do even more...say the third character had to be a digit
  1561. > between 5 and 9 but not 6.  or 1 or 4 or 8 only.  or always R or something.
  1562. > that could help to even make it more complex to get around.
  1563. > and, if you use the reg code to keep track of things (like they're customer
  1564. > number 50 to register, the type of computer they have, or whatever other
  1565. > database/recordkeeping you might want to use), you could have your own
  1566. > sort of "code" for all this built in there, y'know?  just gotta use the
  1567. > imagination :)
  1568.  
  1569. Your method is good. Another scheme, to make the code somewhat harder to
  1570. figure out, is to say create a "hash" code from the last four digits, and
  1571. then make sure that this value matches a predefined value. For instance,
  1572. if we call the last four digits A, B, C and D, you might take the result
  1573. of (((A*B)+C*100)/D) % 10. Then pick a number that marks a valid serial
  1574. number. Let's say that it is 8. For 9632 or 5594 the result is 8. But
  1575. other numbers don't work.
  1576.  
  1577. Try it.
  1578.  
  1579. Mark Coniglio
  1580.  
  1581. -- 
  1582. mail: troika@panix.com
  1583. http: www.art.net/Studios/Performance/Dance/Troika_Ranch/TroikaHome.html
  1584.  
  1585. +++++++++++++++++++++++++++
  1586.  
  1587. >From f-reed@primenet.com (Frank Reed)
  1588. Date: 22 Mar 1996 16:38:01 -0700
  1589. Organization: Primenet
  1590.  
  1591. nordic@inetnebr.com (Dave) wrote:
  1592.  
  1593. >Does anyone have any pointers on how to program registration codes?  I
  1594. >know how to do the dialogs and all of the general programming.  My
  1595. >question is how to set up a system where specific codes will unlock the
  1596. >program.
  1597.  
  1598. I've been following this string with interest because I have a similar
  1599. question, but I'm not sure I understand the big picture.  Perhaps
  1600. someone would be kind enough to tell me if the following scenario is
  1601. substantially correct.
  1602.  
  1603. 1.  A user downloads a shareware program to try it out.  To give users
  1604. an incentive to  register, the registered version of the program
  1605. behaves better in some respect than the shareware version.
  1606.  
  1607. 2.  The user decides to register the program.  To do so, he sends
  1608. money or a credit card number to the vendor along with (and this is
  1609. the part I'm not sure about) some kind of unique information about
  1610. himself or his system, such as his registration name or a code
  1611. generated by the shareware version, perhaps derived from a hard disk
  1612. serial number or BIOS ROM version number.
  1613.  
  1614. 3.  The shareware vendor receives the unique information from the
  1615. purchaser, and from it generates an unlock code, which is sent to the
  1616. purchaser.
  1617.  
  1618. 4.  The purchaser enters the unlock code into a registration dialog in
  1619. the shareware product.  The shareware combines the unique information
  1620. referenced above with the unlock code and determines whether the
  1621. unlock code is valid.  If so, the registered version functionality of
  1622. the product is enabled.
  1623.  
  1624. Is that pretty much the way it works?
  1625.  
  1626. - Frank Reed
  1627.  
  1628.  
  1629.  
  1630. +++++++++++++++++++++++++++
  1631.  
  1632. >From flisakow@fontina.cs.wisc.edu (Shaun Flisakowski)
  1633. Date: 23 Mar 1996 06:56:35 GMT
  1634. Organization: U of Wisconsin CS Dept
  1635.  
  1636. In article <4ivdkp$7r0@nnrp1.news.primenet.com>,
  1637. Frank Reed <f-reed@primenet.com> wrote:
  1638. >nordic@inetnebr.com (Dave) wrote:
  1639. >
  1640. >>Does anyone have any pointers on how to program registration codes?  I
  1641. >>know how to do the dialogs and all of the general programming.  My
  1642. >>question is how to set up a system where specific codes will unlock the
  1643. >>program.
  1644. >
  1645. >I've been following this string with interest because I have a similar
  1646. >question, but I'm not sure I understand the big picture.  Perhaps
  1647. >someone would be kind enough to tell me if the following scenario is
  1648. >substantially correct.
  1649.  
  1650.     Yes, you seem to be dead on. 
  1651.  
  1652. >1.  A user downloads a shareware program to try it out.  To give users
  1653. [snip]
  1654. >
  1655. >2.  The user decides to register the program.  To do so, he sends
  1656. >money or a credit card number to the vendor along with (and this is
  1657. >the part I'm not sure about) some kind of unique information about
  1658. >himself or his system, such as his registration name or a code
  1659. >generated by the shareware version, perhaps derived from a hard disk
  1660. >serial number or BIOS ROM version number.
  1661. [snip]
  1662.  
  1663.     This is the a difficult part, ideally you would like to obtain
  1664.     some number that is unique for each machine, and not going to
  1665.     change if the user reinstalls the OS, obtains new hardware, or
  1666.     gets a divorce.
  1667.  
  1668. -- 
  1669.     Shaun        flisakow@cs.wisc.edu
  1670.  
  1671.    "In your heart you know its flat."
  1672.                            -Flat Earth Society
  1673.  
  1674.  
  1675. +++++++++++++++++++++++++++
  1676.  
  1677. >From weare@galaxy.ucr.edu (christopher weare)
  1678. Date: 23 Mar 1996 00:05:00 -0800
  1679. Organization: University of California, Riverside
  1680.  
  1681. In article <4ivdkp$7r0@nnrp1.news.primenet.com>,
  1682. Frank Reed <f-reed@primenet.com> wrote:
  1683. >2.  The user decides to register the program.  To do so, he sends
  1684. >money or a credit card number to the vendor along with (and this is
  1685. >the part I'm not sure about) some kind of unique information about
  1686. >himself or his system, such as his registration name or a code
  1687. >generated by the shareware version, perhaps derived from a hard disk
  1688. >serial number or BIOS ROM version number.
  1689. >
  1690. Actually, no unique information is needed.  The reg code is usualy a long
  1691. string that has billions or trillions of possible combinations.  However,
  1692. only a small subset of those combinations (determined by some algorithm 
  1693. used by the vendor) is actually valid.  When the user gets the code,
  1694. they type it in and the program simply determines if the code belongs to the 
  1695. small subset of valid codes.
  1696.  
  1697.  
  1698.  
  1699. -chris
  1700.  
  1701.  
  1702. +++++++++++++++++++++++++++
  1703.  
  1704. >From wjohn@webcom.com (Wolfgang John)
  1705. Date: Sat, 23 Mar 1996 16:03:36 GMT
  1706. Organization: Call America Internet Services  +1 (805) 541 6316
  1707.  
  1708. troika@panix.com (Mark Coniglio) wrote:
  1709.  
  1710. >In article <hsoi-1903962303090001@ppp16-17.rns.tamu.edu>, hsoi@tamu.edu
  1711. >(John C. Daub) wrote:
  1712.  
  1713. >> something like, 3 digits, hyphen, 2 digits, 2 letters, 2 digits hypen,
  1714. >> digit, letter, 2 digits.
  1715. >> 
  1716. >> so like:  123-45-AB67-8C90
  1717. >> 
  1718. >> then, you can check for this pattern in your registration dialog code.
  1719. >> 
  1720. >> get the string from the reg dialog, parse it byte by byte.  you can even
  1721. >> do another first check, if not "15" characaters long, reject it...if
  1722. >> it is 15, parse for the "type" of character...like for the first character,
  1723. >> if it's not a digit, reject.
  1724. >> 
  1725. >> and then you could do even more...say the third character had to be a digit
  1726. >> between 5 and 9 but not 6.  or 1 or 4 or 8 only.  or always R or something.
  1727. >> 
  1728. >> that could help to even make it more complex to get around.
  1729. >> 
  1730. >> and, if you use the reg code to keep track of things (like they're customer
  1731. >> number 50 to register, the type of computer they have, or whatever other
  1732. >> database/recordkeeping you might want to use), you could have your own
  1733. >> sort of "code" for all this built in there, y'know?  just gotta use the
  1734. >> imagination :)
  1735. >> 
  1736.  
  1737. >Your method is good. Another scheme, to make the code somewhat harder to
  1738. >figure out, is to say create a "hash" code from the last four digits, and
  1739. >then make sure that this value matches a predefined value. For instance,
  1740. >if we call the last four digits A, B, C and D, you might take the result
  1741. >of (((A*B)+C*100)/D) % 10. Then pick a number that marks a valid serial
  1742. >number. Let's say that it is 8. For 9632 or 5594 the result is 8. But
  1743. >other numbers don't work.
  1744.  
  1745. I often wonder whether "figuring out" a registration code is the
  1746. problem, or is it people passing around the number once they have
  1747. obtained it by registering or other means?
  1748.  
  1749.  
  1750. --
  1751. Wolfgang John    - Shareware -
  1752. wjohn@webcom.com    http://www.webcom.com/wjohn 
  1753.  - Phone Dialer and Logger - CD Player and Library - Win3.1 / Win95
  1754.  
  1755.  
  1756. +++++++++++++++++++++++++++
  1757.  
  1758. >From Brandon Staggs <bstaggs@aloha.net>
  1759. Date: Sat, 23 Mar 1996 09:56:06 -1000
  1760. Organization: Psalm 138:2 KJV
  1761.  
  1762. Frank Reed wrote:
  1763.  
  1764. > 2.  The user decides to register the program.  To do so, he sends
  1765. > money or a credit card number to the vendor along with (and this is
  1766. > the part I'm not sure about) some kind of unique information about
  1767. > himself or his system, such as his registration name or a code
  1768. > generated by the shareware version, perhaps derived from a hard disk
  1769. > serial number or BIOS ROM version number.
  1770.  
  1771. This is one way, but people doing it this was forget that people like to 
  1772. upgrade their computer systems. Suppose you register program X on your 
  1773. 386 and give them your BIOS number or HD format number or whatever. So 
  1774. you love the program, but when you finally get your Super Pentium Pro 
  1775. Plus Gold, 500mhz of course, lo and behold you have a different BIOS 
  1776. number so your favorite program wont work on your new wonder machine. So 
  1777. you have to go back to the vendor (assuming he still is around) and get 
  1778. a new code. What a waste of time and a hassle.
  1779.  
  1780. The program I am currently devoloping uses the person's NAME as the 
  1781. "unique identifier" and just matches up a name with a reg code. Of 
  1782. course he could give it to his friends--but at least if I run into it on 
  1783. the net I know who leaked. You always trade off convienience for a 
  1784. chance your program will be pirated more. To me it seems like such a 
  1785. waste of time to get into this full blown BIOS stuff and a hassle for 
  1786. the user. If someone wants to pirate your program they will--any hacker 
  1787. can jump over copy-protection code. You can find a crack for just about 
  1788. any program out there anyway.
  1789.  
  1790. My program will be coded in such a way that there is nothing I need to 
  1791. send a user when they register excpet for their registration code. Since 
  1792. I don't believe in writing crippleware all I have is one measly nag box 
  1793. that also happens to double as the registration code dialog. Once they 
  1794. put in the reg code it turns of the nag and gets them free updates until 
  1795. I decide to change the registration code scheme when I want more money 
  1796. for the upgrade. No disks to mail or anything. Of course I can charge 
  1797. more if they want everything on disk.
  1798.  
  1799. Happy registrations!
  1800. _____________________________________________________________________
  1801.  Brandon L. Staggs        Psalm 138:2 KJV          bstaggs@aloha.net
  1802.          Home Page: http://www.aloha.net/~bstaggs/index.html
  1803.     King James Bible Page: http://www.aloha.net/~bstaggs/kjb.html
  1804.     Commodore 64 Memories: http://www.aloha.net/~bstaggs/c64.html
  1805.  
  1806. +++++++++++++++++++++++++++
  1807.  
  1808. >From Steve@emer.com (Steve Wilson)
  1809. Date: 23 Mar 1996 20:14:43 GMT
  1810. Organization: Emergent Behavior
  1811.  
  1812. In article <4j07b3$n2q@spool.cs.wisc.edu>, flisakow@fontina.cs.wisc.edu
  1813. (Shaun Flisakowski) wrote:
  1814.  
  1815.  
  1816. >     This is the a difficult part, ideally you would like to obtain
  1817. >     some number that is unique for each machine, and not going to
  1818. >     change if the user reinstalls the OS, obtains new hardware, or
  1819. >     gets a divorce.
  1820.  
  1821. You can use the creation date for the boot volume of the machine.  That
  1822. can be changed, but you have to reformat your HD.
  1823.  
  1824. Steve Wilson
  1825. Emergent Behavior
  1826. (415) 494-6763
  1827. Steve@emer.com
  1828.  
  1829. +++++++++++++++++++++++++++
  1830.  
  1831. >From flisakow@fontina.cs.wisc.edu (Shaun Flisakowski)
  1832. Date: 24 Mar 1996 02:54:56 GMT
  1833. Organization: U of Wisconsin CS Dept
  1834.  
  1835. In article <4j0bbc$f3v@galaxy.ucr.edu>,
  1836. christopher weare <weare@galaxy.ucr.edu> wrote:
  1837. >In article <4ivdkp$7r0@nnrp1.news.primenet.com>,
  1838. >Frank Reed <f-reed@primenet.com> wrote:
  1839.  
  1840. >>the part I'm not sure about) some kind of unique information about
  1841. >>himself or his system, such as his registration name or a code
  1842. >>generated by the shareware version, perhaps derived from a hard disk
  1843. >>serial number or BIOS ROM version number.
  1844.  
  1845. >Actually, no unique information is needed.  The reg code is usualy a long
  1846. >string that has billions or trillions of possible combinations.  However,
  1847. >only a small subset of those combinations (determined by some algorithm 
  1848. >used by the vendor) is actually valid.  When the user gets the code,
  1849. >they type it in and the program simply determines if the code belongs to the 
  1850. >small subset of valid codes.
  1851.  
  1852.     Oh course, then you just gave that person a "global" key to your
  1853.     product, which they are then free to give to all their friends,
  1854.     post onto the Net, or whatever else they like.
  1855.  
  1856.     That certainly would make life easy for pirates, you have eliminated
  1857.     the need to figure out how a valid code is created.
  1858.  
  1859. -- 
  1860.     Shaun        flisakow@cs.wisc.edu
  1861.  
  1862.    "In your heart you know its flat."
  1863.                            -Flat Earth Society
  1864.  
  1865. +++++++++++++++++++++++++++
  1866.  
  1867. >From gumboot@airdmhor.gen.nz (Simon Hosie)
  1868. Date: 25 Mar 1996 01:38:03 +1200
  1869. Organization: Airdmhor : a couple of BBS's, a bunch of people, and a cat.
  1870.  
  1871. Frank Reed:
  1872. > 2.  The user decides to register the program.  To do so, he sends
  1873. > money or a credit card number to the vendor along with (and this is
  1874. > the part I'm not sure about) some kind of unique information about
  1875. > himself or his system, such as his registration name or a code
  1876. > generated by the shareware version, perhaps derived from a hard disk
  1877. > serial number or BIOS ROM version number.
  1878.  
  1879.   Of course.. encode their credit card number (the number that gets the
  1880. money out, I mean) into the registered program - what pillock is going to
  1881. start handing that around?  Better yet, make part of the registration fee a
  1882. photo of them in some form of compromising position so that that can be
  1883. scanned and linked into the registered version in an easily extractable way.
  1884.  
  1885. +++++++++++++++++++++++++++
  1886.  
  1887. >From dickmac@ix.netcom.com (Richard MacDonald)
  1888. Date: Sun, 24 Mar 1996 18:13:12 -0700
  1889. Organization: Netcom
  1890.  
  1891. On 25 Mar 1996 01:38:03 +1200, gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  1892.  
  1893. >
  1894. >  Of course.. encode their credit card number (the number that gets the
  1895. >money out, I mean) into the registered program - what pillock is going to
  1896. >start handing that around?  Better yet, make part of the registration fee a
  1897. >photo of them in some form of compromising position so that that can be
  1898. >scanned and linked into the registered version in an easily extractable way.
  1899.  
  1900. I believe that it is sufficient to use the licensee's name and company name
  1901. (with city,  state if there is no company) to generate the code, then display
  1902. that information prominently on the main screen or window whenever the program
  1903. is run. By encrypting the name and company inside the .EXE file you can prevent
  1904. it from changing. That way if a licensee gives it to someone else it will still
  1905. display his or her name and company when that person uses it. Then all you need
  1906. is someone to report it...
  1907.  
  1908. Dick MacDonald
  1909.  
  1910. +++++++++++++++++++++++++++
  1911.  
  1912. >From steve@tropheus.demon.co.uk (Stephen Wolstenholme)
  1913. Date: Mon, 25 Mar 1996 19:10:03 GMT
  1914. Organization: (none)
  1915.  
  1916. On 22 Mar 1996 16:38:01 -0700, f-reed@primenet.com (Frank Reed) wrote:
  1917.  
  1918.  
  1919. >2.  The user decides to register the program.  To do so, he sends
  1920. >money or a credit card number to the vendor along with (and this is
  1921. >the part I'm not sure about) some kind of unique information about
  1922. >himself or his system, such as his registration name or a code
  1923. >generated by the shareware version, perhaps derived from a hard disk
  1924. >serial number or BIOS ROM version number.
  1925. >
  1926. >3.  The shareware vendor receives the unique information from the
  1927. >purchaser, and from it generates an unlock code, which is sent to the
  1928. >purchaser.
  1929. >
  1930. >4.  The purchaser enters the unlock code into a registration dialog in
  1931. >the shareware product.  The shareware combines the unique information
  1932. >referenced above with the unlock code and determines whether the
  1933. >unlock code is valid.  If so, the registered version functionality of
  1934. >the product is enabled.
  1935.  
  1936. That's more or less what I do. I use the persons name (or company
  1937. name) to generate a registration number. The number and name
  1938. combination stops the application countdown or enables any facilities
  1939. that have been inhibited by the countdown. I don't think it's a very
  1940. good idea to generate a registration number based on something that is
  1941. unique to the system - the software license is owned by the
  1942. person/company not the chunk of hardware that it is running on.
  1943.  
  1944. Steve
  1945.  
  1946. - ------------------------------------------------------------------------
  1947. Stephen Wolstenholme, Cheadle Hulme, Cheshire, UK   
  1948. steve@tropheus.demon.co.uk
  1949.  
  1950. Author of Neural Planner, Windows 3.1x neural network system
  1951. http://www.xmission.com/~wintrnx/regnet/86p.htm
  1952. ftp.demon.co.uk/pub/ibmpc/win3/apps/ai/np400.zip
  1953. ftp.coast.net/SimTel/win3/neurlnet/np400.zip
  1954. - ------------------------------------------------------------------------ 
  1955.  
  1956. +++++++++++++++++++++++++++
  1957.  
  1958. >From Jan.Hertsens@ping.be (Jan Hertsens)
  1959. Date: Tue, 26 Mar 1996 18:02:10 GMT
  1960. Organization: A Forest Software
  1961.  
  1962. Steve@emer.com (Steve Wilson) wrote:
  1963. >
  1964. >You can use the creation date for the boot volume of the machine.  That
  1965. >can be changed, but you have to reformat your HD.
  1966.  
  1967. Or spend 3 minutes writing a program that can read and write this part
  1968. of the bootsector....  
  1969.  
  1970. (Just a thought)
  1971. --
  1972.  
  1973.     Greetz,     _  o   PGP: D7 60 17 56 37 85 B3 69 5A 37 8F EE C5 6A BE 57
  1974.   | _  _.._    |<)_/#  <<< Don't get mad.  Get EVEN.  Get CheatMachine! >>>
  1975. \_|(/_(_|| |   TT  <T  http://www.SliceOfLife.com/Official/AFOREST/CM.HTM
  1976.  
  1977. +++++++++++++++++++++++++++
  1978.  
  1979. >From robin@perth.DIALix.oz.au (Robin Kay)
  1980. Date: 27 Mar 1996 09:35:32 +0800
  1981. Organization: DIALix Services, Perth, Australia.
  1982.  
  1983. Using the Chip ID or Disk drive for registration will be okay if you keep
  1984. track of who has registered.  Then if they upgrade their machine, you can
  1985. give them a new registration number for free.  You will soon know if
  1986. someone is abusing the system:  you wouldn't believe them if they upgraded
  1987. five times in the first month, or "upgraded" from a Pentium to a 486.
  1988.  
  1989. At most someone might get away with one free registration for a friend.
  1990.  
  1991.  
  1992. +++++++++++++++++++++++++++
  1993.  
  1994. >From innovative_technologies@actcom.co.il (innovative technologies)
  1995. Date: Wed, 27 Mar 1996 01:53:33 GMT
  1996. Organization: innovative technologies
  1997.  
  1998.  
  1999. >That's more or less what I do. I use the persons name (or company
  2000. >name) to generate a registration number. The number and name
  2001. >combination stops the application countdown or enables any facilities
  2002. >that have been inhibited by the countdown. I don't think it's a very
  2003. >good idea to generate a registration number based on something that is
  2004. >unique to the system - the software license is owned by the
  2005. >person/company not the chunk of hardware that it is running on.
  2006.  
  2007. >Steve
  2008.  
  2009. Hi Steve,
  2010.  
  2011. How do you handle than SITE licences? Or passing around the S/W
  2012. between friends (especially if your market has limited size)?
  2013. Why not offer any user immidiate new registration if he buys a new
  2014. computer and just sends the receipt?
  2015.  
  2016. best regards,
  2017.  
  2018.         Innovative Technologies
  2019.         Telecom, Multimedia and VoiceMail products
  2020.         and home of the TYIN adavanced utilities.
  2021.         email: innovative_technologies@actcom.co.il
  2022.         Check our WEB site at:
  2023.         WWW:   http://www.israel.net/innovative/
  2024.  
  2025. (note: When responding, please send email in addition to post here).
  2026.  
  2027.  
  2028. +++++++++++++++++++++++++++
  2029.  
  2030. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  2031. Date: Wed, 27 Mar 1996 01:36:24 -0500
  2032. Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  2033.  
  2034. innovative_technologies@actcom.co.il (innovative technologies) writes:
  2035. > >That's more or less what I do. I use the persons name (or company
  2036. > >name) to generate a registration number.
  2037.  
  2038. I find this method relatively unannoying (speaking as a user.) 
  2039.  
  2040. > How do you handle than SITE licences? Or passing around the S/W
  2041. > between friends (especially if your market has limited size)?
  2042.  
  2043. Actually, limited size works the other way. The shareware game I put
  2044. out uses an even weaker scheme; a fixed password. If the players xerox
  2045. the code sheet, they beat the scheme. Somehow, I still make money. I
  2046. once saw a binary patch to bypass the password check on my game, and I
  2047. *still* make money. Why? I wrote a good puzzle-game. People like it.
  2048. They'd rather pay me than cheat me.
  2049.  
  2050. > Why not offer any user immidiate new registration if he buys a new
  2051. > computer and just sends the receipt?
  2052.  
  2053. I'm going to run off a dozen copies of my receipt and mail them to a
  2054. dozen different shareware companies? Yeah, right. Way too much work. 
  2055.  
  2056. Maybe you think that's a lazy attitude, but I'm buying a new computer
  2057. soon, and I don't believe I have *any* shareware programs that I'll
  2058. have to write to the author for a new password. I'll have to spend
  2059. some time retyping the passwords I've gotten in the past three years,
  2060. but they're all in a folder right next to me.
  2061.  
  2062. So my lazy attitude works.
  2063.  
  2064. --Z
  2065.  
  2066. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  2067.  
  2068. +++++++++++++++++++++++++++
  2069.  
  2070. >From andrewwelc@aol.com (AndrewWelc)
  2071. Date: 27 Mar 1996 05:25:48 -0500
  2072. Organization: America Online, Inc. (1-800-827-6364)
  2073.  
  2074. > I find this method relatively unannoying (speaking as a user.)
  2075.  
  2076. Agreed.  The system we use generates a license code based on a product
  2077. name, licensee name and the number of copies they license.  If the program
  2078. is given to a friend, it is automagically unregistered.
  2079.  
  2080. The license codes are all letters (case doesn't matter), which is
  2081. important from a usability point of view for users.
  2082.  
  2083. Any programmer/hack can easily bypass any system you invent, it really
  2084. shouldn't be much of an issue when designing a registration system IMHO. 
  2085. The trickier you get, the more time you waste on it rather than your
  2086. program, and the more of a fun mental exercise you give to folks with the
  2087. expertise.
  2088.  
  2089. Heck, come up with a funky, tricky scheme and then challenge us to break
  2090. it. :)
  2091.  
  2092. +--------------------------------------------------------------+
  2093. |    Andrew Welch - Thaumaturgist - Ambrosia Software, Inc.    |
  2094. +-------------------------------+------------------------------+
  2095. |    AOL-> Keyword: Ambrosia    |  eWorld-> Shortcut: Ambrosia |
  2096. |    CIS-> GO word: Ambrosia    |  http://www.AmbrosiaSW.com/  |
  2097. +-------------------------------+------------------------------+
  2098.  
  2099.  
  2100. ---------------------------
  2101.  
  2102. >From grs124@psu.edu (Greg Simon)
  2103. Subject: How to find CTB devices ?
  2104. Date: Mon, 25 Mar 1996 10:28:30 -0500
  2105. Organization: Penn State University
  2106.  
  2107.  
  2108. What's the proper way to find out what CTB devices (e.g., "Modem Port",
  2109. etc) are available on a machine?
  2110.  
  2111. or, is "Inside the Macintosh Communications Toolbox" online anywhere?
  2112. Thanks, 
  2113.  
  2114. Greg
  2115.  
  2116. -- 
  2117. Greg Simon <grs124@psu.edu>
  2118. Newt's Cape co/Developer
  2119. http://www.netaxs.com/~weyer/newton/newtscape.html
  2120.  
  2121. +++++++++++++++++++++++++++
  2122.  
  2123. >From Jack Littleton <jackal@aimnet.com>
  2124. Date: Mon, 25 Mar 1996 19:19:05 -0800
  2125. Organization: The Windward Group
  2126.  
  2127. Greg Simon wrote:
  2128. > What's the proper way to find out what CTB devices (e.g., "Modem Port",
  2129. > etc) are available on a machine?
  2130.  
  2131. There are some routines in something called the "Communications Resource
  2132. Manager" that are used to find the number and names of serial ports.  I
  2133. haven't seen any documentation, but there is an example of how to use them
  2134. in the Communications Toolbox folder in the snippets folder of the
  2135. developer cd (Tool Chest).Greg Simon wrote:
  2136. --
  2137. Jack Littleton
  2138. The Windward Group (http://www.wwg.com)
  2139. Los Gatos, CA
  2140.  
  2141. +++++++++++++++++++++++++++
  2142.  
  2143. >From mspace@netcom.com (Brian Hall)
  2144. Date: Tue, 26 Mar 1996 00:08:00 GMT
  2145. Organization: Mark/Space Softworks
  2146.  
  2147. grs124@psu.edu (Greg Simon) writes:
  2148.  
  2149.  
  2150. >What's the proper way to find out what CTB devices (e.g., "Modem Port",
  2151. >etc) are available on a machine?
  2152.  
  2153. >or, is "Inside the Macintosh Communications Toolbox" online anywhere?
  2154. >Thanks, 
  2155.  
  2156. See the Communications Resource Manager calls documented in that manual.
  2157. (It is not online, you'll need to buy the book).
  2158.  
  2159. -- 
  2160. __________________________________________________________________________
  2161. Brian Hall, Mark/Space Softworks               Internet: mspace@netcom.com
  2162. Communicate, PageNOW!, CTB Tools                 AppleLink, AOL: MARKSPACE
  2163.              Goodies at <ftp://ftp.netcom.com/pub/ms/mspace>
  2164.  
  2165. +++++++++++++++++++++++++++
  2166.  
  2167. >From russ@aol.com (Russ)
  2168. Date: 27 Mar 1996 11:23:34 -0500
  2169. Organization: America Online, Inc. (1-800-827-6364)
  2170.  
  2171. Greg Simon wrote:
  2172. > What's the proper way to find out what CTB devices (e.g., "Modem Port",
  2173. > etc) are available on a machine?
  2174.  
  2175. On the Apple Web site there is a code snippet that shows exactly how to do
  2176. this, the URL is: 
  2177.  
  2178. http://dev.info.apple.com/source/code/Snippets/Communications_Toolbox/Find
  2179. SerialPorts/ReadMe.html
  2180.  
  2181. I used code based on this in an application of mine and it works fine.
  2182.  
  2183.  
  2184. - ------------------------------------------------
  2185. Russell Easby-Smith        russ@aol.com
  2186.  
  2187. all spelling mistakes contained here are copyright
  2188. 1996 Russell Easby-Smith, all rights reserved.  Any 
  2189. use of them without explicit permission is a violation 
  2190. of copyright laws.
  2191. - --------------------------------------------------
  2192.  
  2193. ---------------------------
  2194.  
  2195. >From Britt.Bolen@Kiski.Org (Britt Bolen)
  2196. Subject: How to make an app scriptable
  2197. Date: Wed, 20 Mar 1996 14:50:04 -0500
  2198. Organization: BB's Custom Software
  2199.  
  2200. How does one begin to make an app scriptable?  I couldn't find anything in
  2201. the old IM books, so I was wondering if someone could point me in the
  2202. right direction to make my app scriptable. Thanks
  2203.  
  2204. Britt
  2205.  
  2206. -- 
  2207. Britt.Bolen@Kiski.Org
  2208.    "And so we beat on, boats against the current, borne back ceaselessly into the past."
  2209. F. Scott Fitzgerald
  2210.  
  2211. +++++++++++++++++++++++++++
  2212.  
  2213. >From pottier@chaland.ens.fr (Francois Pottier)
  2214. Date: 21 Mar 1996 08:31:25 GMT
  2215. Organization: Ecole Normale Superieure, Paris
  2216.  
  2217. In article <Britt.Bolen-2003961450040001@beck_17s.citynet.net>,
  2218. Britt Bolen <Britt.Bolen@Kiski.Org> wrote:
  2219.  
  2220. >How does one begin to make an app scriptable?  I couldn't find anything in
  2221. >the old IM books, so I was wondering if someone could point me in the
  2222. >right direction to make my app scriptable. Thanks
  2223.  
  2224. It isn't easy. The whole thing is rather neatly thought out but there
  2225. is a lot to learn.
  2226.  
  2227. The main reference book is NIM:IAC (Inter-Application Communication),
  2228. and you will also need the Apple Event Registry which contains a list
  2229. of standard events.
  2230.  
  2231. Then, there have many interesting articles on this topic in past
  2232. issues of Develop (from 17 or so up to now). You should check them
  2233. out. Finally, you should probably use a framework which will help you
  2234. handle the AEOM - one of the Develop articles gives one and explains
  2235. it, there is another one embedded in PowerPlant (read the source code
  2236. in the Apple Events folder).
  2237.  
  2238. I hope this helps,
  2239.  
  2240. -- 
  2241. Francois Pottier
  2242. Francois.Pottier@ens.fr
  2243. Francois.Pottier@inria.fr
  2244. http://www.eleves.ens.fr:8080/home/pottier/
  2245.  
  2246. +++++++++++++++++++++++++++
  2247.  
  2248. >From mortensen@embl-heidelberg.de (Peter Mortensen)
  2249. Date: 28 Mar 1996 21:40:13 GMT
  2250. Organization: EMBL
  2251.  
  2252. In article <4ir44t$rc0@nef.ens.fr>
  2253. pottier@chaland.ens.fr (Francois Pottier) writes:
  2254.  
  2255. >>How does one begin to make an app scriptable?  I couldn't find anything in
  2256. >>the old IM books, so I was wondering if someone could point me in the
  2257. >>right direction to make my app scriptable. Thanks
  2258. >Then, there have many interesting articles on this topic in past
  2259. >issues of Develop (from 17 or so up to now). You should check them
  2260. >out. Finally, you should probably use a framework which will help you
  2261.  
  2262. For design of the script interface (not the implementation) these fine
  2263. articles will help you make your application's script interface at
  2264. least as good as any current commmercial application's script
  2265. interface:
  2266.  
  2267.   
  2268. Cal Simone. Develop. Issue 21, March 1995.
  2269.     Designing a Scripting Implementation. Page 48-72.
  2270.  
  2271. Cal Simone. Develop. Issue 22, June 1995. ACCORDING TO SCRIPT column.
  2272.     Scripting Quandaries. Page 81-82.
  2273.  
  2274. Cal Simone. Develop. Issue 23, September 1995. ACCORDING TO SCRIPT
  2275. column.
  2276.     Thinking About Dictionaries. Page 90-93.
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283. Regards,
  2284. Peter Mortensen
  2285.  
  2286.  
  2287. - ----------------------------------------------------------------------
  2288.  
  2289. Peter Mortensen,                    E-mail:
  2290. mortensen@embl-heidelberg.de    
  2291. Software Engineer, M.Sc.E.E.                    FAX: +49 (0)6221 387
  2292. 306
  2293. European Molecular Biology Laboratory (EMBL)  Phone: +49 (0)6221 387
  2294. 560
  2295. http://www.mann.embl-heidelberg.de/PPG/PersonalPages/PeterM/PeterM.html
  2296.  
  2297. ---------------------------
  2298.  
  2299. >From Manuel Veloso <veloso@apix.com>
  2300. Subject: Macsbug 6.5.3 slower at stepping?
  2301. Date: Tue, 26 Mar 1996 00:34:36 GMT
  2302. Organization: Active Paper, Inc.
  2303.  
  2304. I and a couple of others at the office are using Macsbug 6.5.3
  2305. now, and have noticed a large slowdown in the step/trace times on
  2306. our machines. It takes almost a second (well, a lot more time) to
  2307. step/trace than in 6.5.2.
  2308.  
  2309. Has anyone else noticed? Both of us are running macsbug off
  2310. of our internal video, with the other monitor running off a
  2311. card.
  2312.  
  2313. - ---------------------------------------
  2314. Manny Veloso          Digital Plumber
  2315. Active Paper, Inc.    http://www.apix.com
  2316. - ---------------------------------------
  2317. 4%
  2318.  
  2319.  
  2320. +++++++++++++++++++++++++++
  2321.  
  2322. >From mvgfr@netcom.com (Marc Farnum Rendino)
  2323. Date: Tue, 26 Mar 1996 15:02:29 GMT
  2324. Organization: mvgfr
  2325.  
  2326. On Tue, 26 Mar 1996 00:34:36 GMT, Manuel Veloso (veloso@apix.com)
  2327. wrote (<DouMxo.D0A@sig.net>):
  2328.  
  2329. > I and a couple of others at the office are using Macsbug 6.5.3
  2330. > now, and have noticed a large slowdown in the step/trace times
  2331.  
  2332. FWIW, I noticed a blurb in the release notes about showing more info
  2333. on environment changes (eg: err codes) while stepping.
  2334.  
  2335. - Marc
  2336.  
  2337. +++++++++++++++++++++++++++
  2338.  
  2339. >From jumplong@aol.com (Jump Long)
  2340. Date: 27 Mar 1996 02:05:41 -0500
  2341. Organization: America Online, Inc. (1-800-827-6364)
  2342.  
  2343. Manny Veloso wrote:
  2344. >I and a couple of others at the office are using Macsbug 6.5.3
  2345. >now, and have noticed a large slowdown in the step/trace times
  2346. >on our machines. It takes almost a second (well, a lot more
  2347. >time) to step/trace than in 6.5.2.
  2348. >
  2349. >Has anyone else noticed? Both of us are running macsbug off of
  2350. >our internal video, with the other monitor running off a card.
  2351.  
  2352. Manny, are you by chance debugging Magic Cap code in the Magic Cap
  2353. simulator? :-) If so, then I think I know the problem and a solution.
  2354.  
  2355. When debugging a Magic Cap program using the Magic Cap simulator, you've
  2356. got a *very* large chunk of 68K code, it's in one *big* Macintosh memory
  2357. block, and it has *lots* of MacsBug symbols.
  2358.  
  2359. With MacsBug 6.5.3, support for native PowerPC debugging was improved a
  2360. lot, but it made searching for symbols in a memory block slower on Power
  2361. Macintosh systems because each block is searched for both 68K and CFM
  2362. symbols. With smaller memory blocks, you'll probably never notice the
  2363. slowdown. However, when you're dealing with a memory block the size you
  2364. get with the Magic Cap simulator, the slow-down is very noticable. 
  2365.  
  2366. What can you do? Make MacsBug think it's running on a 68K system. To do
  2367. that, you remove the 'mxnx' resource in MacsBug. Note that this means that
  2368. you lose all PowerPC debugging enhancements in MacsBug, but if you're only
  2369. debugging 68K code, that probably won't bother you much.
  2370.  
  2371. I suggested to Jim Murphy righ that he add a MacsBug command to tell it to
  2372. only look for 68K symbols. I'll check again to see if that can be added in
  2373. the future.
  2374.  
  2375. - Jim Luther
  2376.  
  2377. jumplong@aol.com
  2378. <http://members.aol.com/JumpLong/>
  2379.  
  2380. +++++++++++++++++++++++++++
  2381.  
  2382. >From Manuel Veloso <veloso@apix.com>
  2383. Date: Thu, 28 Mar 1996 22:35:48 GMT
  2384. Organization: Active Paper, Inc.
  2385.  
  2386. In article <4japc5$3cu@newsbf02.news.aol.com> Jump Long, jumplong@aol.com
  2387. writes:
  2388. >
  2389. >Manny, are you by chance debugging Magic Cap code in the Magic Cap
  2390. >simulator? :-) If so, then I think I know the problem and a solution.
  2391.  
  2392. Why yes!
  2393.  
  2394. >What can you do? Make MacsBug think it's running on a 68K system. To do
  2395. >that, you remove the 'mxnx' resource in MacsBug. Note that this means that
  2396. >you lose all PowerPC debugging enhancements in MacsBug, but if you're only
  2397. >debugging 68K code, that probably won't bother you much.
  2398.  
  2399. Will do. I guess, though, I won't be able to tell if a crash was due to
  2400. something I was doing in the simulator or some random system death :P.
  2401. - ---------------------------------------
  2402. Manny Veloso          Digital Plumber
  2403. Active Paper, Inc.    http://www.apix.com
  2404. - ---------------------------------------
  2405. cranking towards Sunnyvale
  2406. waiting to be shipped? :P
  2407.  
  2408. +++++++++++++++++++++++++++
  2409.  
  2410. >From roy@earthlight.co.nz (Roy Ward)
  2411. Date: Sun, 31 Mar 1996 21:49:23 +1200
  2412. Organization: none
  2413.  
  2414. In article <4japc5$3cu@newsbf02.news.aol.com>,
  2415. jumplong@aol.com (Jump Long) wrote:
  2416.  
  2417. >What can you do? Make MacsBug think it's running on a 68K system. To do
  2418. >that, you remove the 'mxnx' resource in MacsBug. Note that this means that
  2419. >you lose all PowerPC debugging enhancements in MacsBug, but if you're only
  2420. >debugging 68K code, that probably won't bother you much.
  2421.  
  2422. Or depending on what you are doing, use 'sx' to toggle off the symbols.
  2423. That's what I do in very big code blocks with 6.5.2, and it is a massive
  2424. speed increase.
  2425.  
  2426. Roy.
  2427.  
  2428.  
  2429.  
  2430.  
  2431. ---------------------------
  2432.  
  2433. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  2434. Subject: NewGWorld Memory Leak?
  2435. Date: Fri, 08 Mar 1996 17:51:19 -0500
  2436. Organization: Utility Reduction Specialists, Inc.
  2437.  
  2438. I've been using ZoneRanger 1.6 to track down some memory leaks and noticed
  2439. that NewGWorld allocates 26 handles, but DisposeGWorld only deallocates
  2440. 24. Anyone have any idea why? The only bit I set in the flags is
  2441. noNewDevice.
  2442.  
  2443. Thanks,
  2444.  
  2445. Dave
  2446.  
  2447. -- 
  2448. David B. Zwiefelhofer
  2449. Utility Reduction Specialists, Inc.
  2450. 1605 Monroe Street, Suite 110
  2451. Madison, WI  53211-2052
  2452. (608) 258-8965
  2453. (608) 258-9686 FAX
  2454.  
  2455. +++++++++++++++++++++++++++
  2456.  
  2457. >From cameron_esfahani@powertalk.apple.com (Cameron Esfahani)
  2458. Date: Wed, 20 Mar 1996 21:52:00 GMT
  2459. Organization: Apple Computer, Inc.
  2460.  
  2461. This memory leak has been fixed in 7.5.3.
  2462.  
  2463. Cameron Esfahani
  2464.  
  2465. +++++++++++++++++++++++++++
  2466.  
  2467. >From boxtop@aris.com (boxtop)
  2468. Date: 22 Mar 1996 04:23:36 GMT
  2469. Organization: BoxTop Software
  2470.  
  2471. In article <cameron_esfahani-2003961352000001@a17-202-33-245.apple.com>
  2472. cameron_esfahani@powertalk.apple.com (Cameron Esfahani) writes:
  2473.  
  2474. > This memory leak has been fixed in 7.5.3.
  2475. > Cameron Esfahani
  2476.  
  2477. @*%^!! I've been looking for this same leak thinking it was my code!
  2478. Nice to know it wasn't, but since the app in question relies heavily on
  2479. GWorlds the amount of the leaking going on adds up to a significant
  2480. amount and it not being my fault is little consolance. Short of
  2481. rewriting the thing from the ground up the high reliance on GWorlds
  2482. can't go so is there any way to get ahold of said left over 2 handles
  2483. to dispose of them manually?? Or would that divuldge some great
  2484. mystical secret of the GWorld?
  2485.  
  2486. Travis Anton,
  2487. -- BoxTop Software
  2488.  
  2489. boxtop@aris.com | http://www.aris.com/boxtop | ftp://aris.com/boxtop
  2490.  
  2491. ________________ "Making the tools that make the web." ________________
  2492.  
  2493. ProJPEGv1.0.1 a Mac Photoshop file-format plug-in brings progressive
  2494. JPEG
  2495. support to your favorite image processing program with 'open and save'
  2496. ease and, makes significant improvements over Photoshop's built in JPEG
  2497. support that not only let you make progressive JPEGs but also let you 
  2498. make the smallest baseline JPEGs possible.
  2499.  
  2500. PhotoGIFv1.1.4 the only file-format plug-in support for transparent and
  2501. interlaced GIF89a (And interlaced 87a's) files and unquestionably the 
  2502. best tool for creating GIF graphics with Photoshop. "The Net Magazine" 
  2503. called it "invaluable". Take a look and find out for yourself why.
  2504.  
  2505. +++++++++++++++++++++++++++
  2506.  
  2507. >From tonyn@tiac.net (Tony Nelson)
  2508. Date: Wed, 27 Mar 1996 21:47:55 -0500
  2509. Organization: The Internet Access Company
  2510.  
  2511. In article <4ita08$k6j@NNTP.MsState.Edu>, boxtop@aris.com (boxtop) wrote:
  2512.  
  2513. > ... Short of
  2514. > rewriting the thing from the ground up the high reliance on GWorlds
  2515. > can't go so is there any way to get ahold of said left over 2 handles
  2516. > to dispose of them manually?? Or would that divuldge some great
  2517. > mystical secret of the GWorld?
  2518.  
  2519. Since the leak happens when _NewGWorld is called, why not just leave the
  2520. GWorld around and use it again?  If it takes too much memory, you can call
  2521. _AllowPurgePixels.
  2522. ____________________________________________________________________
  2523. TonyN.:'                                              tonyn@tiac.net
  2524.       '
  2525.  
  2526.  
  2527. +++++++++++++++++++++++++++
  2528.  
  2529. >From AppleGG@lamg.com (Gordon Apple)
  2530. Date: 31 Mar 1996 11:24:03 GMT
  2531. Organization: Los Angeles Macintosh Group BBS
  2532.  
  2533. Eric Shapiro,Shapiro@AOL.com,Internet writes:
  2534. The nice thing about this method is that it works really well for raw
  2535. animation files or digitized graphics because you control the rowBytes
  2536. value instead of having NewGWorld assign you one. For some of my old code,
  2537. this allows me to read in several animation frames directly into a single 
  2538. big buffer and just manipulate the baseAddr for each frame. (You *could* 
  2539. do this with GWorlds, but you'd be mucking with something you're not 
  2540. supposed to muck with).
  2541. - -----------------------------------------
  2542.  
  2543.      Along that line, I'm using GWorlds for a 4-bit offscreen and am storing
  2544. the rseults in a file.  Because I was not sure exactly how the bytes align, I
  2545. write out one big block for the image, but before that I write out the value
  2546. of rowbytes.  When I read it in, I get the rowbytes of the GWorld on the
  2547. maching that is doing the reading so that I can read one row at a time and
  2548. adjust for differences in row-bytes.
  2549.  
  2550.      I started doing this when I realized that the PCI macs have an extra
  2551. 16-bytes per row instead of the extra 4-bytes I was used to in older Macs.
  2552.  
  2553. (Side Note:)
  2554.     If you are reading a CTable from a resource for use for your GWorld (or
  2555. any other reason for that matter) BEWARE THE 7.5.3 NATIVE RESOURCE MANAGER. 
  2556. Be sure you use GetCTable, not GetResource.  The latter won't work anymore
  2557. for this purpose. (Trust me.)
  2558.  
  2559.  
  2560.  
  2561. G. Gordon apple, PhD
  2562. Advanced Communications Engineering, Inc.
  2563. Redondo Beach, CA
  2564.  
  2565.  
  2566. +++++++++++++++++++++++++++
  2567.  
  2568. >From Shapiro@AOL.com (Eric Shapiro)
  2569. Date: Fri, 29 Mar 1996 11:49:17 -0500
  2570. Organization: Rock Ridge Enterprises
  2571.  
  2572. > > In article <DaveZ-0803961751190001@msn_7_3.binc.net>, DaveZ@mailbag.com
  2573. > > (David B. Zwiefelhofer) wrote:
  2574. > > 
  2575. > > > I've been using ZoneRanger 1.6 to track down some memory leaks and noticed
  2576. > > > that NewGWorld allocates 26 handles, but DisposeGWorld only deallocates
  2577. > > > 24. Anyone have any idea why? The only bit I set in the flags is
  2578. > > > noNewDevice.
  2579.  
  2580. You can "roll your own" GWorlds. It isn't simple, except that there's a 
  2581. tech note that explains exactly how to do it. 
  2582.  
  2583. You create a GDevice and CGrafPort, allocate the PixMap, etc, etc.
  2584.  
  2585. The nice thing about this method is that it works really well for raw
  2586. animation files or digitized graphics because you control the rowBytes
  2587. value instead of having NewGWorld assign you one. For some of my old code,
  2588. this allows me to read in several animation frames directly into a single 
  2589. big buffer and just manipulate the baseAddr for each frame. (You *could* 
  2590. do this with GWorlds, but you'd be mucking with something you're not 
  2591. supposed to muck with).
  2592.  
  2593.  -Eric
  2594.  
  2595. -- 
  2596. Eric Shapiro
  2597. Rock Ridge Enterprises
  2598. shapiro@aol.com
  2599.  
  2600.  
  2601. ---------------------------
  2602.  
  2603. >From mars@netcom.com (Darren Giles)
  2604. Subject: Optimizing RGB pixel operations on PPC?
  2605. Date: Mon, 11 Mar 1996 22:21:33 GMT
  2606. Organization: Terran Interactive
  2607.  
  2608. I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  2609. I'm trying to find the most optimal way to perform pixel manipulations.
  2610.  
  2611. The code snippet below illustrates my current approach.  It takes a series
  2612. of pixels, and adjusts the red & green values.
  2613.  
  2614. There are a number of smallish things to play with (like whether to have
  2615. intermediate values or just one big formula) -- but what I'm wondering is,
  2616. is there a substantially better approach that I'm overlooking?
  2617.  
  2618.  
  2619.  
  2620. #define RED_BYTE(x)  (x>>16 & 0x000000ff)
  2621. #define GREEN_BYTE(x) (x>>8 & 0x000000ff)
  2622. #define BLUE_BYTE(x)     (x & 0x000000ff)
  2623.  
  2624.  
  2625. while (src_addr < last_src_addr) {
  2626.         // read source pixel
  2627.         long  pixel_value= *src_addr++;
  2628.         
  2629.         // adjust brightness of red + green channels
  2630.         long  red= RED_BYTE(pixel_value) * red_scale;
  2631.         long  green= RED_BYTE(pixel_value) * green_scale;
  2632.         long  blue= RED_BYTE(pixel_value);
  2633.         
  2634.         // write destination pixel
  2635.         *dst_addrr++ = red << 16 | green << 8 | blue;
  2636. }
  2637.  
  2638. Any suggestions greatly appreciated!
  2639.  
  2640. - Darren
  2641.  
  2642. ==========================================================================
  2643. Darren Giles, Technical Director                        Terran Interactive
  2644. For info on Cleaner QuickTime compression, visit http://www.Terran-Int.com
  2645.  
  2646. +++++++++++++++++++++++++++
  2647.  
  2648. >From kptben@aol.com (KPT Ben)
  2649. Date: 12 Mar 1996 22:22:50 -0500
  2650. Organization: America Online, Inc. (1-800-827-6364)
  2651.  
  2652. ian@five-d.com (Ian Kemmish) wrote:
  2653. >On a RISC (any RISC....) you want to avoid integer multiplies like the
  2654. plague.
  2655. >Do all your calculations in floating point up until after the last
  2656. multiply, 
  2657. >and then (and only then) convert to integers.  Even on the old R2000, a 
  2658. >floating multiply was nearly three times as fast as an integer multiply,
  2659. and 
  2660. >things have generally got worse since then....
  2661.  
  2662. Not necessarily true.  For an operation such as multiplying two RGB pixels
  2663. using integer math, we'd have code something like 
  2664.  
  2665. uint32 PixMult(uint32 p1, uint32 p2) {  // uint32 == unsigned long
  2666.     uint32 r1,g1,b1;
  2667.     uint32 r2,g2,b2;
  2668.     uint32 r,g,b;
  2669.  
  2670.     r1 = RedByte(p1); g1 = GreenByte(p1); b1 = BlueByte(p1); // unpack
  2671. first pixel
  2672.     r2 = RedByte(p2); g2 = GreenByte(p2); b2 = BlueByte(p2); // unpack
  2673. second pixel
  2674.  
  2675.     r = (r1 * r2) >> 8; // multiply channels
  2676.     g = (g1 * g2) >> 8;
  2677.     b = (b1 * b2) >> 8;
  2678.     
  2679.     return r << 16 | g << 8 | b; // pack destination pixel
  2680.     }
  2681.  
  2682. which involves 6 instructions to unpack the components, three integer
  2683. multiply/shifts, and four instructions to reassemble the result.
  2684.  
  2685. On a PPC601, this takes a total of 25 cycles. On a 604, it can be done in
  2686. about 10 cycles.
  2687.  
  2688. To put this in perspective, converting a SINGLE integer value to
  2689. floating-point and back on PPC takes about 8-10 cycles. Here you'd have to
  2690. convert SIX values to floating-point (then convert three back to integer),
  2691. a HIDEOUS amount of overhead to get to the floating-point multiplies
  2692. (which on the 604 are the same speed as integer multiplies; 1-3 cycles
  2693. faster than integer on the 601).
  2694.  
  2695. The Moto 601/604 PowerPC manuals are a very useful read on this topic.
  2696.  
  2697. Happy coding,
  2698.  
  2699. --
  2700. Ben Weiss
  2701. Senior Software Engineer
  2702. MetaTools Inc. (formerly HSC Software)
  2703.  
  2704. +++++++++++++++++++++++++++
  2705.  
  2706. >From kptben@aol.com (KPT Ben)
  2707. Date: 12 Mar 1996 02:11:24 -0500
  2708. Organization: America Online, Inc. (1-800-827-6364)
  2709.  
  2710. mars@netcom.com (Darren Giles) wrote:
  2711.  
  2712. >I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  2713. >I'm trying to find the most optimal way to perform pixel manipulations.
  2714. >
  2715. >The code snippet below illustrates my current approach.  It takes a
  2716. series
  2717. >of pixels, and adjusts the red & green values.
  2718. >
  2719. >There are a number of smallish things to play with (like whether to have
  2720. >intermediate values or just one big formula) -- but what I'm wondering
  2721. is,
  2722. >is there a substantially better approach that I'm overlooking?
  2723.  
  2724. >#define RED_BYTE(x)  (x>>16 & 0x000000ff)
  2725. >#define GREEN_BYTE(x) (x>>8 & 0x000000ff)
  2726. >#define BLUE_BYTE(x)     (x & 0x000000ff)
  2727. >
  2728. >
  2729. >while (src_addr < last_src_addr) {
  2730. >        // read source pixel
  2731. >        long  pixel_value= *src_addr++;
  2732. >        
  2733. >        // adjust brightness of red + green channels
  2734. >        long  red= RED_BYTE(pixel_value) * red_scale;
  2735. >        long  green= RED_BYTE(pixel_value) * green_scale;
  2736. >        long  blue= RED_BYTE(pixel_value);
  2737. >        
  2738. >        // write destination pixel
  2739. >        *dst_addrr++ = red << 16 | green << 8 | blue;
  2740. >}
  2741.  
  2742. What type are the values red_scale and green_scale?  if they're
  2743. floating-point, you'll take a huge hit here.
  2744.  
  2745. Good luck,
  2746.  
  2747. --
  2748. Ben Weiss
  2749. Senior Software Engineer
  2750. MetaTools Inc. (formerly HSC Software)
  2751.  
  2752. +++++++++++++++++++++++++++
  2753.  
  2754. >From Paul Tuckfield <c11533@detroitedison.com>
  2755. Date: Wed, 13 Mar 1996 11:34:31 -0500
  2756. Organization: Detroit Edison Co.
  2757.  
  2758. On Tue, 12 Mar 1996, David Matiskella wrote:
  2759.  
  2760. > On 12 Mar 1996, KPT Ben wrote:
  2761. > > mars@netcom.com (Darren Giles) wrote:
  2762. > > 
  2763. > > >I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  2764. > > >I'm trying to find the most optimal way to perform pixel manipulations.
  2765. . . .
  2766. > > >is there a substantially better approach that I'm overlooking?
  2767. > > 
  2768. > > >#define RED_BYTE(x)  (x>>16 & 0x000000ff)
  2769. > > >#define GREEN_BYTE(x) (x>>8 & 0x000000ff)
  2770. > > >#define BLUE_BYTE(x)     (x & 0x000000ff)
  2771. > > >
  2772. > > >
  2773. > > >while (src_addr < last_src_addr) {
  2774. > > >        // read source pixel
  2775. > > >        long  pixel_value= *src_addr++;
  2776. > > >        
  2777. > > >        // adjust brightness of red + green channels
  2778. > > >        long  red= RED_BYTE(pixel_value) * red_scale;
  2779. > > >        long  green= RED_BYTE(pixel_value) * green_scale;
  2780. > > >        long  blue= RED_BYTE(pixel_value);
  2781. > > >        
  2782. > > >        // write destination pixel
  2783. > > >        *dst_addrr++ = red << 16 | green << 8 | blue;
  2784. > > >}
  2785. > > 
  2786. > > What type are the values red_scale and green_scale?  if they're
  2787. > > floating-point, you'll take a huge hit here.
  2788. > I second Ben point that you most likely want to be doing this as a fixed 
  2789. > point calcuation if possible. Otherwise the time to convert and int to a 
  2790.  
  2791. Maybe I'm missing something, but they appear to be integers to me based on 
  2792. context.(I thought the floting point types were "float" and "double" in C?)
  2793.  
  2794. Also, I think your red and green channels need to be masked after the
  2795. scailing, so that bits in the green cannel dont "spillover" into the 
  2796. red channel when > 255, likewise with red spilling over into the alpha 
  2797. channel.
  2798.  
  2799.  Anyway I think the big thing is to move the calculations that are 
  2800. constants out of the loop rather than recalculate each time.  Also avoid 
  2801. extra copies to temp buffers when possible:
  2802.  
  2803. // these were done *every* iteration in your loop, now just once
  2804.  
  2805. shifted_red_scale  =red_scale  <<16 & 0x00FF0000 ;
  2806. shifted_green_scale=green_scale<<8  & 0x0000FF00 ;
  2807.  
  2808. while (src_addr < last_src_addr){
  2809.   *dst_addr++=(((*src_addr & 0x00FF0000)*shifted_red_scale) & 0x00FF000)
  2810.             | (((*src_addr & 0x0000FF00)*shifted_green_scale) & 0x0000FF00)
  2811.             |   (*src_addr & 0xFF0000FF); //preserve alpha and blue chan.
  2812.   src_addr++;
  2813. }
  2814.  
  2815. I'm a bit weak on order of operations, but you should be able to put the
  2816. src_addr++ in either the first or last multiply saving a C statement, and
  2817. possibly cycles as well if there is a postincrement type access on ppc.
  2818. (an associate of mine has just informed me that postincrement order is
  2819. not defined if you stuck it inside the calculation, so maybe you need
  2820. to leave it where it is)
  2821.  
  2822. If I've over parenthesized, it's for clarity and shouldn't cause
  2823. a performance hit in the compiler, since if you were an order of operations
  2824. whiz, and didn't use parens, the object code should be the same anyway (?)
  2825.  
  2826. I think the next step would be trying to analyze dependencies in this
  2827. statement so as to optimize for the ppc pipeline and superscalar 
  2828. architecture.
  2829.  
  2830. That is, you may want to bust this back out into three channels, each
  2831. channel result is a register, then or the registers at the end   . playing
  2832. with the order in which you scale the channels, then use the results in
  2833. the final oring, might optimize pipeline dependencies (?) and avoid a
  2834. possible stall (?).  Also might allow superscalars to dispatch two
  2835. instructions (?) en route to the result.
  2836.  
  2837.  
  2838. +++++++++++++++++++++++++++
  2839.  
  2840. >From verec@micronet.fr (Jean-Francois Brouillet)
  2841. Date: Tue, 12 Mar 1996 17:28:19 +0100
  2842. Organization: Francenet -- Paris, France
  2843.  
  2844. In article <mars-1103961426480001@192.0.2.1>, mars@netcom.com (Darren
  2845. Giles) wrote:
  2846.  
  2847. >I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  2848. >I'm trying to find the most optimal way to perform pixel manipulations.
  2849. >
  2850. >The code snippet below illustrates my current approach.  It takes a series
  2851. >of pixels, and adjusts the red & green values.
  2852. >
  2853. >There are a number of smallish things to play with (like whether to have
  2854. >intermediate values or just one big formula) -- but what I'm wondering is,
  2855. >is there a substantially better approach that I'm overlooking?
  2856. >
  2857. >
  2858. >
  2859. >#define RED_BYTE(x)  (x>>16 & 0x000000ff)
  2860. >#define GREEN_BYTE(x) (x>>8 & 0x000000ff)
  2861. >#define BLUE_BYTE(x)     (x & 0x000000ff)
  2862. >
  2863. >
  2864. >while (src_addr < last_src_addr) {
  2865. >        // read source pixel
  2866. >        long  pixel_value= *src_addr++;
  2867. >        
  2868. >        // adjust brightness of red + green channels
  2869. >        long  red= RED_BYTE(pixel_value) * red_scale;
  2870. >        long  green= RED_BYTE(pixel_value) * green_scale;
  2871. >        long  blue= RED_BYTE(pixel_value);
  2872. >        
  2873. >        // write destination pixel
  2874. >        *dst_addrr++ = red << 16 | green << 8 | blue;
  2875. >}
  2876. >
  2877. >Any suggestions greatly appreciated!
  2878. >
  2879. >- Darren
  2880. >
  2881. >==========================================================================
  2882. >Darren Giles, Technical Director                        Terran Interactive
  2883. >For info on Cleaner QuickTime compression, visit http://www.Terran-Int.com
  2884.  
  2885. Just my two cents...
  2886.  
  2887. what about :
  2888.  
  2889. while (src_addr < last_src_addr) {
  2890.     // get a pointer on alpha byte, increment src_addr by four bytes
  2891.     unsigned char *p = (unsigned char *) ((long *) src_addr++);
  2892.  
  2893.     ++p;    //  skip alpha chan.
  2894.     *p *= red_scale;
  2895.     ++p;    //  go next chan.
  2896.     *p *= green_scale;
  2897.  
  2898.     // no need to do anything with blue chan, so just let the next
  2899.     // iteration reajust ``p'' on next pixel boundary.
  2900. }
  2901.  
  2902. I didn't test, and don't have a C ref manual handy but perhaps you could
  2903. even try something like :
  2904.  
  2905.     (*++p) *= red_scale;
  2906.     (*++p) *= green_scale;
  2907.  
  2908. With an heavy optimizing compiler (and provided that this is correct C
  2909. code which does what I suppose it does) you may get vast improvments ???
  2910.  
  2911. -- 
  2912. Jean-Francois Brouillet              verec@micronet.fr
  2913. Macintosh Software Developer     verecundus@eworld.com
  2914.  
  2915. +++++++++++++++++++++++++++
  2916.  
  2917. >From David Matiskella <matiskel@aa.washington.edu>
  2918. Date: Tue, 12 Mar 1996 09:47:23 -0800
  2919. Organization: University of Washington
  2920.  
  2921. On 12 Mar 1996, KPT Ben wrote:
  2922.  
  2923. > mars@netcom.com (Darren Giles) wrote:
  2924. > >I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  2925. > >I'm trying to find the most optimal way to perform pixel manipulations.
  2926. > >
  2927. > >The code snippet below illustrates my current approach.  It takes a
  2928. > series
  2929. > >of pixels, and adjusts the red & green values.
  2930. > >
  2931. > >There are a number of smallish things to play with (like whether to have
  2932. > >intermediate values or just one big formula) -- but what I'm wondering
  2933. > is,
  2934. > >is there a substantially better approach that I'm overlooking?
  2935. > >#define RED_BYTE(x)  (x>>16 & 0x000000ff)
  2936. > >#define GREEN_BYTE(x) (x>>8 & 0x000000ff)
  2937. > >#define BLUE_BYTE(x)     (x & 0x000000ff)
  2938. > >
  2939. > >
  2940. > >while (src_addr < last_src_addr) {
  2941. > >        // read source pixel
  2942. > >        long  pixel_value= *src_addr++;
  2943. > >        
  2944. > >        // adjust brightness of red + green channels
  2945. > >        long  red= RED_BYTE(pixel_value) * red_scale;
  2946. > >        long  green= RED_BYTE(pixel_value) * green_scale;
  2947. > >        long  blue= RED_BYTE(pixel_value);
  2948. > >        
  2949. > >        // write destination pixel
  2950. > >        *dst_addrr++ = red << 16 | green << 8 | blue;
  2951. > >}
  2952. > What type are the values red_scale and green_scale?  if they're
  2953. > floating-point, you'll take a huge hit here.
  2954. > Good luck,
  2955. > --
  2956. > Ben Weiss
  2957. > Senior Software Engineer
  2958. > MetaTools Inc. (formerly HSC Software)
  2959. I second Ben point that you most likely want to be doing this as a fixed 
  2960. point calcuation if possible. Otherwise the time to convert and int to a 
  2961. float, convert a float to an int and store and load the value while most
  2962. likely take as much time as the rest of the calculations. Other than that 
  2963. you might want to look at the assembly code of the procedure. the 
  2964. RED_BYTE macro should only require 1 instruction if the optimizer is any 
  2965. good. Similiar using preincrement instead of postincrement maps better to 
  2966. the powerpc instruction set. A really code compiler should do this for 
  2967. you but I have not been too impressed with the current state of the art 
  2968. powerpc compilers.
  2969.  
  2970.  David Matiskella
  2971. matiskel@aa.washington.edu
  2972.  
  2973.  
  2974.  
  2975. +++++++++++++++++++++++++++
  2976.  
  2977. >From ian@five-d.com (Ian Kemmish)
  2978. Date: 12 Mar 1996 18:21:24 GMT
  2979. Organization: At home with Ian
  2980.  
  2981. In article <mars-1103961426480001@192.0.2.1>, mars@netcom.com says...
  2982.  
  2983.  
  2984. >There are a number of smallish things to play with (like whether to have
  2985. >intermediate values or just one big formula) -- but what I'm wondering is,
  2986. >is there a substantially better approach that I'm overlooking?
  2987.  
  2988. >while (src_addr < last_src_addr) {
  2989. >        // read source pixel
  2990. >        long  pixel_value= *src_addr++;
  2991. >        
  2992. >        // adjust brightness of red + green channels
  2993. >        long  red= RED_BYTE(pixel_value) * red_scale;
  2994. >        long  green= RED_BYTE(pixel_value) * green_scale;
  2995. >        long  blue= RED_BYTE(pixel_value);
  2996. >        
  2997. >        // write destination pixel
  2998. >        *dst_addrr++ = red << 16 | green << 8 | blue;
  2999. >}
  3000. >
  3001.  
  3002. On a RISC (any RISC....) you want to avoid integer multiplies like the plague.
  3003. Do all your calculations in floating point up until after the last multiply, 
  3004. and then (and only then) convert to integers.  Even on the old R2000, a 
  3005. floating multiply was nearly three times as fast as an integer multiply, and 
  3006. things have generally got worse since then....
  3007.  
  3008. If you really are constrained to do this operation on a pre-existing raster, 
  3009. then use a lookup table to do the multiply.  Also, on most RISCs, a byte read 
  3010. and byte write are faster than a word read followed by a shift-and-mask.  You 
  3011. won't suffer from doing consecutive byte writes for the red and green pixels 
  3012. on any system with decent write buffers.
  3013.  
  3014.  
  3015. ============================================================================
  3016. Ian Kemmish                 18 Durham Close, Biggleswade, Beds SG18 8HZ
  3017. ian@five-d.com              Tel: +44 1767 601 361   Fax: +44 1767 312 006
  3018. Info on Jaws and 5D's other products on http://www.five-d.com/5d
  3019. ============================================================================
  3020. `The customer is King, but the proprietor is God'
  3021.  
  3022.  
  3023. +++++++++++++++++++++++++++
  3024.  
  3025. >From David Matiskella <matiskel@aa.washington.edu>
  3026. Date: Wed, 13 Mar 1996 09:18:33 -0800
  3027. Organization: University of Washington
  3028.  
  3029. On 12 Mar 1996, KPT Ben wrote:
  3030.  
  3031. > ian@five-d.com (Ian Kemmish) wrote:
  3032. > >On a RISC (any RISC....) you want to avoid integer multiplies like the
  3033. > plague.
  3034. > >Do all your calculations in floating point up until after the last
  3035. > multiply, 
  3036. > >and then (and only then) convert to integers.  Even on the old R2000, a 
  3037. > >floating multiply was nearly three times as fast as an integer multiply,
  3038. > and 
  3039. > >things have generally got worse since then....
  3040. > Not necessarily true.  For an operation such as multiplying two RGB pixels
  3041. > using integer math, we'd have code something like 
  3042. > uint32 PixMult(uint32 p1, uint32 p2) {  // uint32 == unsigned long
  3043. >     uint32 r1,g1,b1;
  3044. >     uint32 r2,g2,b2;
  3045. >     uint32 r,g,b;
  3046. >     r1 = RedByte(p1); g1 = GreenByte(p1); b1 = BlueByte(p1); // unpack
  3047. > first pixel
  3048. >     r2 = RedByte(p2); g2 = GreenByte(p2); b2 = BlueByte(p2); // unpack
  3049. > second pixel
  3050. >     r = (r1 * r2) >> 8; // multiply channels
  3051. >     g = (g1 * g2) >> 8;
  3052. >     b = (b1 * b2) >> 8;
  3053. >     
  3054. >     return r << 16 | g << 8 | b; // pack destination pixel
  3055. >     }
  3056. > which involves 6 instructions to unpack the components, three integer
  3057. > multiply/shifts, and four instructions to reassemble the result.
  3058. > On a PPC601, this takes a total of 25 cycles. On a 604, it can be done in
  3059. > about 10 cycles.
  3060. > To put this in perspective, converting a SINGLE integer value to
  3061. > floating-point and back on PPC takes about 8-10 cycles. Here you'd have to
  3062. > convert SIX values to floating-point (then convert three back to integer),
  3063. > a HIDEOUS amount of overhead to get to the floating-point multiplies
  3064. > (which on the 604 are the same speed as integer multiplies; 1-3 cycles
  3065. > faster than integer on the 601).
  3066. > The Moto 601/604 PowerPC manuals are a very useful read on this topic.
  3067. > Happy coding,
  3068. > --
  3069. > Ben Weiss
  3070. > Senior Software Engineer
  3071. > MetaTools Inc. (formerly HSC Software)
  3072. One other minor thing I remembered is that you want to multiply by the 
  3073. smaller number. ie if your scale is a 16 bit number it should read 
  3074. scale*redbyte rather than redbyte*scale. The compiler will have trouble 
  3075. with an optimization like this since it has no idea of the size of the 
  3076. variables.(Although it should be able to determine the size of redbtye). 
  3077. As far as I know reading a word and a byte are the same speed on a 
  3078. powerpc. On a 603 or 604 with there separate LSU units you probaly could 
  3079. make the routine faster by reading bytes but I think it would be slower 
  3080. on a 601. 
  3081.  David Matiskella
  3082. matiskel@aa.washington.edu
  3083.  
  3084.  
  3085.  
  3086. +++++++++++++++++++++++++++
  3087.  
  3088. >From more@stekt.oulu.fi (Jyrki Alakuijala)
  3089. Date: 14 Mar 1996 17:11:31 GMT
  3090. Organization: (none)
  3091.  
  3092. The following "benchmarking" is done on Alpha:
  3093. long[char] takes about 730 "clicks" on Alpha.
  3094. char * char takes about 2000 "clicks"
  3095. bitshift takes some 420 "clicks"
  3096.  
  3097. >On a RISC (any RISC....) you want to avoid integer multiplies like the plague.
  3098.  
  3099. This is simply not true any more. There are a lot of risc processors that
  3100. have fast integer multipliers. Alpha spend 3600 "clicks" on long * long and
  3101. about 5200 on double * double. float * float was around 2800. char * long
  3102. is faster than any floating point combination.
  3103.  
  3104. >then use a lookup table to do the multiply.  Also, on most RISCs, a byte read 
  3105.  
  3106. I agree completely. Lookup tables are fast on most architectures.
  3107. You might even want to consider a lookup table that would have
  3108. green and blue combined:
  3109.  
  3110. unsigned long redLookup[256]; 
  3111. // (redLookup uses 1024 bytes of ram)
  3112.  
  3113. unsigned short greenBlueLookup[65536];  
  3114. // (greenBlueLookup uses 128kB of ram :-( )
  3115.  
  3116. Then you could use these as follows:
  3117.  
  3118. *dst_addrr++ = redLookup[longValue >> 16] + 
  3119.   greenBlueLookup[longValue & 0xffff];
  3120.  
  3121. In some cases it is good practice to build your bitmap correctly
  3122. from the beginning. Then you would not have any need to
  3123. travel through it again at this time. :-)
  3124.  
  3125. Please, let us know which approach you find fastest.
  3126.  
  3127. --Jyrki
  3128.  
  3129.  
  3130. +++++++++++++++++++++++++++
  3131.  
  3132. >From pasbesoin@pasici.pasla
  3133. Date: 18 Mar 1996 16:33:58 GMT
  3134. Organization: IConNet
  3135.  
  3136.  How do you get the value of the RGB pixel 
  3137. using GetCPixel from grafptr or do you have something better ???
  3138.  
  3139. +++++++++++++++++++++++++++
  3140.  
  3141. >From Shapiro@AOL.com (Eric Shapiro)
  3142. Date: Sun, 24 Mar 1996 14:05:57 -0500
  3143. Organization: Rock Ridge Enterprises
  3144.  
  3145. In article <mars-1103961426480001@192.0.2.1>, mars@netcom.com (Darren
  3146. Giles) wrote:
  3147.  
  3148. > I'm doing a lot of work with 32-bit bitmap manipulation on a PowerPC, and
  3149. > I'm trying to find the most optimal way to perform pixel manipulations.
  3150.  
  3151. While normally I try and stay away from writing PowerPC assembly
  3152. language, pixel manipulation is one case where you can really 
  3153. speed up routines by using assembly.
  3154.  
  3155. The PowerPC architecture has a "shift w/mask" instruction that 
  3156. extracts pixel values from bitmaps very quickly. You might want
  3157. to disassemble your code to see if the compiler is smart enough
  3158. to use these instructions. If not, consider assembly.
  3159.   
  3160. I don't think you can multiply all of the component values in 
  3161. a single multiply instruction, especially since overflowing the
  3162. lower bytes will affect the values in the higher ones.
  3163.  
  3164.  -Eric
  3165.  
  3166. -- 
  3167. Eric Shapiro
  3168. Rock Ridge Enterprises
  3169. shapiro@aol.com
  3170.  
  3171. ---------------------------
  3172.  
  3173. >From mxmora@mxmdesigns.com (Matthew Xavier Mora)
  3174. Subject: UMPA Awards Last week for Nominations
  3175. Date: 31 Mar 1996 07:06:31 GMT
  3176. Organization: MXM Designs™
  3177.  
  3178.  
  3179. Announcing The Second Annual USENET Macintosh Programming Awards 
  3180. UMPA 1996
  3181. sponsored by Bare Bones Software and Metrowerks 
  3182.  
  3183. We have been getting a lot of prizes thanks to some evanglizing from
  3184. Jordan Mattson. Thanks Jordan. Keep the nominations comming in! 
  3185.  
  3186. So the list of prizes so far is:
  3187.  
  3188. Every winner will get this stuff:
  3189. - UMPA T -Shirt
  3190. - UMPA Plaque.
  3191. - $100.00 Cash Prize (Oooh!)
  3192. - $100.00 APDA Gift Certificate (from Juan Bettaglio ) 
  3193. - A Self Paced Course from DU (from Jennifer Martin) 
  3194. - One year free membership in the Associates Plus or AMP program 
  3195. ( Or an extension if currently enrolled from Cindy Gallie) 
  3196.  
  3197. The things below will go to the winners of the ShareWare, Freeware,
  3198. Support and Smart friend categories only since the Commercial winner has
  3199. all this stuff anyway.
  3200.  
  3201. - Lots o' Symantec Stuff (includes Mac C++ and Java tools) 
  3202. (from Will Iverson)
  3203. t-shirts, option for any Symantec product NFR (e.g. a choice of C++ Win,
  3204. ACT!, Norton, etc.). - Apprentice CD (From Paul Celestin )
  3205.  
  3206. - BBEdit and BBEdit T-shirts (From Rich Siegel) 
  3207. - Metrowerks Gold CD and buch of other stuff
  3208. - QC by Onyx Technology from Devon Hubbard and Brooks Bell 
  3209. - Roaster the Java Development Environment from Natural Intelligence 
  3210.  
  3211.  
  3212. A big thanks to our sponsors!
  3213.  
  3214. So send in your nominations!
  3215.  
  3216. Matt
  3217.  
  3218. - -----------------------------------------------------------
  3219. U M P A
  3220. - ----------------------------------------------------------- 
  3221.  
  3222. It looks like its time for the Second Annual Usenet Macintosh Programming
  3223. Awards (UMPA). For those of you that have never heard of this before, last
  3224. year we created the UMPA awards to honor our peers in the Mac Programming
  3225. world. Often a program itself will get awarded but the person(s)
  3226. responsible for creating the product never get their due recognition for a
  3227. job well done. This award is to honor those in the trenches fighting the
  3228. good fight for the Macintosh. 
  3229.  
  3230. This is the last week of nomination. I'm letting the nomination run a week
  3231. longer than normal because I'll be out of town until April 6th.
  3232.  
  3233.  
  3234. Here is a list of the categories: 
  3235.  
  3236. Outstanding Programming for a Commercial Product. 
  3237.  
  3238. Outstanding Programming for a Shareware Product. 
  3239.  
  3240. Outstanding Programming for a Freeware Product 
  3241.  
  3242. Outstanding Support of the Mac programming community. (usually from a non
  3243. programmer)
  3244.  
  3245. Official SmartFriend(tm) award for the most helpful c.s.m.p.* net citizen.
  3246.  
  3247.  
  3248. Here is a list of the current nominees (Remember we are nominating the
  3249. programmers not the product so please include the name of the
  3250. programmer(s)):
  3251.  
  3252.  
  3253. Outstanding Programming for a Commercial Product: 
  3254. 1. Rich Siegel for BBEdit
  3255. 2. Jordan Zimmerman for QuickView/MPTA
  3256. 3. Alan Bird for OneClick (WestCode Software)
  3257. 4. Devon Hubbard and Brooks Bell for QC
  3258. 5. Jud Spencer for Claris Emailer
  3259. 6. Marcel Achim for CW Pascal compiler
  3260. 7. Claris team (Tom Hoke, Scott Holdaway, Scott Lindsey, Bob Hearn, Ben
  3261. Chang, Bruce Hammond, Mate Gross) for ClarisWorks 
  3262. 8. Jason Jones (Bungie Software) for Marathon. 
  3263. 9. Mark Adams, Ken Cobb, Jim Hamilton, Mike Korte, Robert Thurman,  Ken
  3264. Offer and Tim Hall (GraceLAN Network Management Series)
  3265. 10. Kai Krause and Ben Wiess for their amazing code. 
  3266. 11. Brian Sutter, the author of Installer VISE 
  3267. 12. Brian Hall(?) of Mark/Space for PageNow! 
  3268. 13. Richard Zulch, author of Retrospect and Retrospect Remote
  3269. 14. John McEnerny of Metrowerks for the CW C++ compiler.
  3270. 15. Eric Scouten for Constructor
  3271.  
  3272. Outstanding Programming for a Shareware Product: 
  3273. 1. Mitch Jones for Snitch
  3274. 2. Gilles Berkovitch for Glidel
  3275. 3. Leonard Rosenthol, Marshall Clow and Crew for Stuffit products. 
  3276. 4. David Waring for Swoop from Ambrosia
  3277. 5. Kurt Piersol, Jens Alfke, Jon Pugh, and the rest of 
  3278. the OpenDoc team for best programming for a shareware product OpenDoc 
  3279. 6. Andrew Welch for all his cool games
  3280. 7. Text-Edit Plus by Tom Bender
  3281. 8. Style by Marco Piavonelli
  3282. 9. Greg Landweber and Ed Voas for Aaron. 
  3283. 10. Francois Pottier for Decor.
  3284. 11. John Brochu for CalcWorks.
  3285. 12. Jerry Aman for PageSpinner
  3286. 13. Alberto Ricci for SoundEffects
  3287. 14. Ted Leckie, Tom Andersen, Peter Hanson for StarryNight 
  3288. 15. Peter Keleher - Alpha text editor
  3289. 16. Richard C Cardona for Click! There it is 
  3290. 17. Samuel, David and Andreas Rydh for Note Pad Deluxe
  3291. 18. Scott Sykes for Netscape Defrost
  3292.  
  3293. Peter Lewis respectfully declines the nomination. 
  3294.  
  3295. Outstanding Programming for a Freeware Product: 
  3296. 1. Michael Hecht for ResCompare
  3297. 2. Steve Dagley, Richard Reynolds, and Co. for FreePPP. 
  3298. 3. Lindsay Davies and Carles Bellver for HTML tools for BBEdit 
  3299. 4. Quinn the Eskimo & Peter for IC
  3300. 5. John Norstad!
  3301. 6. Aaron Giles for JPEGView
  3302. 7. Matthias Neeracher for MacPerl
  3303. 8. Chris W Johnson for the SIVC system
  3304. 9. Rick Holzgrafe for The Tilery
  3305. 10. Chad Magendanz for ShrinkWrap.
  3306. 11. The MicroMat team for TechTool.
  3307. 12. Marco Piovanelli for WASTE Text Engine
  3308. 13. Brian Clark - Yet Another NewsWatcher
  3309. 14. Wayne Rasband for "NIH-Image"
  3310. 15. James Thomson for his coolware DragThing
  3311.  
  3312. Outstanding Support of the Mac programming community: 
  3313. 1. The folks at MetroWerks
  3314. 2. Neil Ticktin of MacTech Magazine
  3315. 3. Natural Intelligence , for Roaster.
  3316. 4. Ron Liechty (MWRon), for his continually outstanding support at c.s.m.p.cw
  3317. 5. John Norstad!
  3318. 6. Paul Celestin for Apprentice and his other great CDs 7. Jim Luther
  3319. 7. Ric Ford and Rick LePage of Macintouch.
  3320. 8. Dan Crevier
  3321. 9. Ken Long
  3322.  
  3323. Official SmartFriend(tm) award :
  3324. 1. Jon Pugh, for many of his insights on AppleScript 
  3325. 2. dEVoN Hubbard
  3326. 3. Pete Gontier
  3327. 4. Garry Hornbuckle, for his great help with OT's startup hiccups 
  3328. 5. Quinn, the Eskimo for OT support
  3329. 6. Jim Luther for his file system knowledge 
  3330. 8. Tim Olson for is PowerPC knowledge
  3331. 9. Lars Farm 
  3332. 10. Greg Robbins at Apple
  3333.  
  3334. The list of final nominees is chosen by the number times that programmer
  3335. was nominated. So if you want your favorite programmer to make the
  3336. nomination cut, Send in his/her name. Since this is the last post until
  3337. we start voting,  sending in a new name of a programmer probably won't do
  3338. much good but you still can if you like.
  3339.  
  3340. Since this award is supposed to be recognition from our peers, You will
  3341. need to answer a Macintosh programming question to have a valid
  3342. nomination.
  3343.  
  3344. The first question is:
  3345.  
  3346. What is the recommended sleep value for WaitNextEvent for a foreground
  3347. Application. :-)
  3348.  
  3349.  
  3350. So send me your nominations <mailto:mxmora@mxmdesigns.com> with what you
  3351. "think" is the correct answer to the above question and I will keep
  3352. updating the nomination list. Here is the URL for the UMPA home page.
  3353. <http://www.best.com/~mxmora/UMPA.html>
  3354.  
  3355. If you would like to donate prizes to this cause, please send me email
  3356. <mailto:mxmora@mxmdesigns.com>. Last year we collected 5 prizes for each
  3357. category. This year I think we should just collect 4 prizes since the
  3358. "Outstanding Programming for a Commercial Product" winner already had all
  3359. the stuff we collected last year. The award,t-shirt, plaque, cash and
  3360. other goodies is probably honor enough. 
  3361.  
  3362. Thanks for listening and good luck to the nominees! 
  3363.  
  3364.  
  3365. Xavier
  3366.  
  3367. ---------------------------
  3368.  
  3369. >From jumplong@aol.com (Jump Long)
  3370. Subject: [ANN] MoreFiles v1.4.2 now available
  3371. Date: 26 Mar 1996 01:03:14 -0500
  3372. Organization: America Online, Inc. (1-800-827-6364)
  3373.  
  3374. MoreFiles is a collection of high-level routines written over the last
  3375. couple of years to answer File Manager questions developers have sent to
  3376. Apple Developer Technical Support and to answer questions on various
  3377. online services and the internet. The routines have been tested (but not
  3378. stress-tested), documented, code-reviewed, and used in both my own
  3379. programs and in many commercial products.
  3380.  
  3381. MoreFiles version 1.4.2, is now available today at:
  3382.  
  3383.   ftp://members.aol.com/JumpLong/MoreFiles_1.4.2.sea.hqx
  3384.  
  3385. MoreFiles version 1.4.2 will also be submitted for release through various
  3386. other means including:
  3387.  
  3388.   Apple Computer (Developer CD, ftp, AppleLink, etc.)
  3389.   America Online (Macintosh Developers Forum)
  3390.   CompuServe (Macintosh Developers Forum)
  3391.   macgifts@mac.archive.umich.edu
  3392.  
  3393. Since I have no control over those means of delivery, they'll show up when
  3394. they show up...
  3395.  
  3396. Enjoy!
  3397.  
  3398. - Jim Luther
  3399.  
  3400. jumplong@aol.com
  3401. <http://members.aol.com/JumpLong/>
  3402. ________________________________________
  3403.  
  3404. Here are the release notes for MoreFiles 1.4.2:
  3405.  
  3406. v1.4.2  3/25/96
  3407.  
  3408. New Routines:
  3409. *  Added FSpResolveFileIDRef to MoreFiles.
  3410. *  Added GetIOACUser and FSpGetIOACUser to MoreFilesExtras. These routines
  3411. let you get a directory's access privileges for the current user.
  3412. *  Added bit masks, macros, and function for testing ioACUser values to
  3413. MoreFilesExtras.h and MoreFilesExtras.p.
  3414. *  Added GetVolumeInfoNoName to MoreFilesExtras to put common calls to
  3415. PBHGetVInfo in one place. Functions that call GetVolumeInfoNoName are: (in
  3416. DirectoryCopy.c) PreflightDirectoryCopySpace, (in FileCopy.c)
  3417. PreflightFileCopySpace, (in MoreFilesExtras.c) DetermineVRefNum,
  3418. CheckVolLock, FindDrive, UnmountAndEject, (in Search.c) CheckVol.
  3419. *  Added GetCatInfoNoName to MoreFilesExtras to put common calls to
  3420. PBGetCatInfo in one place. Functions that call GetCatInfoNoName are: (in
  3421. FileCopy.c) GetDestinationDirInfo, (in MoreDesktopMgr.c) GetCommentID, (in
  3422. MoreFilesExtras.c) GetDInfo, GetDirectoryID, CheckObjectLock.
  3423. *  Added TruncPString to MoreFilesExtras. This lets you shorten a Pascal
  3424. string without breaking the string in the middle of a multi-byte
  3425. character.
  3426. *  Added FilteredDirectoryCopy and FSpFilteredDirectoryCopy to
  3427. DirectoryCopy. FilteredDirectoryCopy and FSpFilteredDirectoryCopy work
  3428. just like DirectoryCopy and FSpDirectoryCopy only they both take an
  3429. optional CopyFilterProc parameter which can point to routine you supply.
  3430. The CopyFilterProc lets your code decide what files or directories are
  3431. copied to the destination. DirectoryCopy and FSpDirectoryCopy now call
  3432. through to FilteredDirectoryCopy with a NULL CopyFilterProc.
  3433.  
  3434. Bugs fixed:
  3435. *  Fixed minor bug in GetDiskBlocks where driveQElementPtr->dQRefNum was
  3436. checked when driveQElementPtr could be NULL.
  3437. *  DirectoryCopy didn't handle error conditions correctly. In some cases,
  3438. DirectoryCopy would return noErr when there was a problem and in other
  3439. cases, the CopyErrProc wasn't called and the function immediately failed.
  3440. *  The result of DirectoryCopy's CopyErrProc was documented incorrectly.
  3441.  
  3442. Other changes and improvements:
  3443. *  Added result codes to function descriptions in the C header files
  3444. (these probably aren't a perfect list of possible errors, but they should
  3445. catch most of the results you'll ever see).
  3446. *  Removed most of the function descriptions in Pascal interface files
  3447. since they haven't been completely in sync with the C headers for some
  3448. time and I don't have time to keep the documentation in both places up to
  3449. date.
  3450. *  Rewrote HMoveRenameCompat so it doesn't use the Temporary Items folder.
  3451. *  Added parameter checking to OnLine so that it doesn't allow the
  3452. volIndex parameter to be less than or equal to 0.
  3453. *  Added parameter checking to GetDirItems so that it doesn't allow the
  3454. itemIndex parameter to be less than or equal to 0.
  3455. *  FSpExchangeFilesCompat now returns diffVolErr (instead of paramErr) if
  3456. the source and the destination are on different volumes.
  3457. *  Changed GetDirName's name parameter to Str31 and added parameter
  3458. checking so that it doesn't allow a NULL name parameter.
  3459. *  Forced errors returned by MoreDesktopMgr routines to be closer to what
  3460. would be expected if the low-level Desktop Manager calls were used.
  3461. *  Added conditionalized changes from Fabrizio Oddone so that Pascal
  3462. calling conventions can be easily disabled. Disabling Pascal calling
  3463. conventions reduces the code size slightly and allows C compilers to
  3464. optimize parameter passing. NOTE: If you disable Pascal calling
  3465. conventions, you'll have to remove the "pascal" keyword from all of the
  3466. MoreFiles callbacks you've defined in your code.
  3467. *  Changed DirectoryCopy so that you can copy the source directory's
  3468. content to a disk's root directory.
  3469. *  Added a build script and a make file for MPW libraries.
  3470. *  Added a build script for Metrowerks CodeWarrior libraries.
  3471. *  Added a build script for Symantec THINK Project Manager and Symantec
  3472. Project Manager libraries.
  3473. *  Renamed the Symantec and Metrowerks project files.
  3474. *  Changed MoreFile's directory structure so that C headers, Pascal
  3475. interfaces, and the source code aren't in the main directory.
  3476.  
  3477. Thanks to Fabrizio Oddone for supplying the conditionalized changes that
  3478. optionally remove Pascal calling conventions. Thanks to Byron Han for
  3479. beating the bugs out of DirectoryCopy and for suggesting and prototyping
  3480. the changes needed for the "copy to root directory" option and the
  3481. FilteredDirectoryCopy routine in DirectoryCopy.
  3482. ________________________________________
  3483.  
  3484.  
  3485. ---------------------------
  3486.  
  3487. >From greenhut@mindspring.com (Jeff Greenhut)
  3488. Subject: [Q] Selecting a Serial Port
  3489. Date: 2 Apr 1996 22:18:45 GMT
  3490. Organization: MindSpring Enterprises
  3491.  
  3492. What is the correct way to select from available serial ports? I have
  3493. heard I should use the CTB, but can't find any doc or examples on the
  3494. developer reference disks(or on the Mac OS SDK disks)
  3495.  
  3496. I want to allow the user to select the modem's port, and wish to support
  3497. Powerbooks, PC cards...
  3498.  
  3499. THANKS!!!
  3500.  
  3501. jeff
  3502.  
  3503. -- 
  3504. Jeff Greenhut
  3505. greenhut@mindspring.com
  3506.  
  3507. +++++++++++++++++++++++++++
  3508.  
  3509. >From blob@ccnet.com
  3510. Date: Tue, 02 Apr 1996 21:28:11 -0800
  3511. Organization: CCnet Communications (510-988-7140 guest)
  3512.  
  3513. In article <greenhut-0204961724170001@news.mindspring.com>,
  3514. greenhut@mindspring.com (Jeff Greenhut) wrote:
  3515. >What is the correct way to select from available serial ports?
  3516.  
  3517. >From the comp.sys.mac.programmer FAQ at <http://www.best.com/~ckt/csmp-faq.html>
  3518.  
  3519.  
  3520.  
  3521. 7.1) Q: How do I get at the serial ports?
  3522.  
  3523. A: You call OpenDriver for the names "/p.AOut" and "/p.AIn" to get at 
  3524. the modem port, and "/p.BOut" and "/p.BIn" for the printer port. The 
  3525. function RAMSDOpen was designed for the original Mac with 128 kB of 
  3526. memory and 64 kB of ROM, and has been extinct for several years.
  3527. However, many users use their serial ports for MIDI, LocalTalk, graphic 
  3528. tablets, or what have you and have installed an additional serial port 
  3529. card to get more ports. What you SHOULD do as a good application is to 
  3530. use the Comm Toolbox Resource Manager to search for serial resources; 
  3531. this requires that the Comms Toolbox is present (true on earlier System 
  3532. 6 with an INIT, on later System 6 and System 7 always, as well as on 
  3533. A/UX) and that you have initialized the comms resource manager. The 
  3534. exact code follows (adapted from Inside Mac Comms Toolbox):
  3535.  
  3536.  #include "CommResources.h"
  3537.  OSErr
  3538.  FindPorts ( Handle * portOutNames, Handle * portInNames, Handle * names,
  3539.              Handle * iconHandles )
  3540.  {
  3541.  
  3542.     OSErr ret = noErr ;
  3543.     short old = 0 ;
  3544.     CRMRec theCRMRec , * found ;
  3545.     CRMSerialRecord * serial ;
  3546.  
  3547.     * portOutNames = NewHandle ( 0L ) ;
  3548.     * portInNames = NewHandle ( 0L ) ;
  3549.     * names = NewHandle ( 0L ) ;
  3550.     * iconHandles = NewHandle ( 0L ) ;
  3551.     while ( ! ret ) {
  3552.         theCRMRec . crmDeviceType = crmSerialDevice ;
  3553.         theCRMRec . crmDeviceID = old ;
  3554.         found = ( CRMRec * ) CRMSearch ( ( QElementPtr ) & theCRMRec ) ;
  3555.         if ( found ) {
  3556.             serial = ( CRMSerialRecord * ) found -> crmAttributes ;
  3557.             old = found -> crmDeviceID ;
  3558.             PtrAndHand ( & serial -> outputDriverName , * portOutNames ,
  3559.                 sizeof ( serial -> outputDriverName ) ) ;
  3560.             PtrAndHand ( & serial -> inputDriverName , * portInNames ,
  3561.                 sizeof ( serial -> inputDriverName ) ) ;
  3562.             PtrAndHand ( & serial -> name , * names , 
  3563.                 sizeof ( serial -> name ) ) ;
  3564.             PtrAndHand ( & serial -> deviceIcon , * iconHandles ,
  3565.                 sizeof ( serial -> deviceIcon ) ) ;
  3566.         } else {
  3567.             break ;
  3568.         }
  3569.     }
  3570.     return err ;
  3571.  }
  3572. This will create four handles with the driver names, device names and 
  3573. driver icon handles for all of the available serial devices. Then let 
  3574. the user choose with a pop-up menu or scrolling list, and save the 
  3575. choice in your settings file.
  3576. You can use OpenDriver, SetReset, SetHShake, SetSetBuf, SerGetBuf and 
  3577. the other Serial Manager functions on these drivers. To write to the 
  3578. serial port, use FSWrite for synchronous writes that wait until all is 
  3579. written, or PBWrite asynchronously for queuing up data that is supposed 
  3580. to go out but you don't want to wait for it. At least once each time 
  3581. through your event loop, you should call SerGetBuf on the in driver 
  3582. reference number you got from OpenDriver, and call FSRead for that many 
  3583. bytes - neither more nor less.
  3584. If you are REALLY interested in doing the right thing, you will use the 
  3585. Communications Toolbox Connection Manager instead; this will give you 
  3586. access to modems, direct lines, and networks of various kinds using the 
  3587. same API! Great for stuff like BBSes that may be on a network as well 
  3588. etc. The Comms Toolbox also provides modularized terminal emulation and 
  3589. file transfer tools, although the Apple-suplied VT102 tool is pretty 
  3590. lame, as is the VT102 mode of the VT320 tool.
  3591.  
  3592. *****
  3593.  
  3594. See also the "FindSerialPorts" sample code, which does the same thing, on
  3595. the tool chest developer CD.
  3596.  
  3597. -- 
  3598. "There are 3 kinds of people in the world; those who can count well enough to divide the world into 3 kinds of people, and those who can't."
  3599.  
  3600. ---------------------------
  3601.  
  3602. End of C.S.M.P. Digest
  3603. **********************
  3604.  
  3605.  
  3606.  
  3607.